1 (edited by teco049 2018-04-03 13:08:14)

Topic: SOLVED: Change background color every xx rows

Hi to all,


does anybody know how what I need to setup for an automatic color changing every xx row in a table?


To have it better readable I want a different background color every 2 or 3 rows.


Thank you in advance.

Re: SOLVED: Change background color every xx rows

Hello.


Example, for every two:

procedure Form1_GridEmployees_OnChange (Sender: string);
var
   iRow ,c: integer;
   q, iCol: integer;
begin
     c := Form1.GridEmployees.RowCount - 1;
     q := Form1.GridEmployees.Columns.Count-1;
     Form1.GridEmployees.BeginUpdate;
     for iRow := 0 to c do
         for iCol := 0 to q do
         begin
             if iRow mod 2 = 0 then Form1.GridEmployees.Cell[iCol,iRow].Color := clBtnFace;
         end;
     Form1.GridEmployees.EndUpdate;
end;

for every 3

 if iRow mod 3 = 0 then Form1.GridEmployees.Cell[iCol,iRow].Color := clBtnFace;

for every 4

 if iRow mod 4 = 0 then Form1.GridEmployees.Cell[iCol,iRow].Color := clBtnFace;

and so on...

Dmitry.

Re: SOLVED: Change background color every xx rows

Hi Dmitry,


Thank you for the sample and source code.


Sorry, I have forgetten to write that I want to have this in a printed report. So I need an information how to do it in Fastreport too.


Thank you.
Teco049

Re: SOLVED: Change background color every xx rows

Hello.


More info:
https://www.fast-report.com/documentati … a_row).htm


Also I made an example for you:

Post's attachments

Attachment icon Report strip rows.zip 6.05 kb, 529 downloads since 2018-04-02 

Dmitry.

Re: SOLVED: Change background color every xx rows

Thank you.
Works perfect.