How to show data at Fast Report in 3*3 grid format?

前端 未结 2 1176
一向
一向 2020-12-20 06:03

I want to display data from table (column :- ID) at FastReport in Grid format as shown below. Suppose there are 22 records in table then it would display same in 3 * 3 grid

2条回答
  •  不知归路
    2020-12-20 06:46

    Public variable declarations

      public
        i: integer;
        myid: Array Of Integer;
        mydesc: Array Of String;
        k: Integer;
        rowcount: Integer;
    

    Code at FormCreate event

    begin
        i := 0;
        k := 0;
        UniTable1.SQL.Text := 'Select * from userplays';
        UniTable1.Execute;
        rowcount := UniTable1.RecordCount;
        SetLength(myid, rowcount);
        SetLength(mydesc, rowcount);
    
          while not UniTable1.Eof do
          begin
             myid[k] := UniTable1.FieldByName('id').Value;
             mydesc[k] := UniTable1.FieldByName('description').Value;
             UniTable1.Next;
             inc(k);
          end;
    end.
    

    Code at OnGetValue event of the frxReport

    var
      j: Integer;
    
    begin
     j := i div 2;
     if j < rowcount then
       begin
    
         if (VarName = 'ID1') then
           Value :=  myid[j];
    
         if (VarName = 'DESC1') then
           Value :=  mydesc[j];
    
       end
     inc(i);
    

    Above ID1 and DESC1 are two variable declared at frxReport memo, value assigned to it at OnGetValue event with the help of global Array myid & mydesc. Global arrays myid & mydesc are filled with database field values at FormCreate event.

提交回复
热议问题