Topic: color rows alternately on a tablegrid when there are many records
I use the procedure below to alternately color the lines of a tablegrid. This routine, I found here in this forum.
However, navigation slows down on a 22 row tablegrid because it is linked to a table with 4000 records. I noticed that using the tablegrid dblimit of 22 lines, the browsing speed is good. But,
As you scroll down the tablegrid, the colors fade. Can anyone help?
procedure ColorRowGrid (Grid:TdbStringGridEx;ColorEven,ColorOdd:TColor;ajusta:boolean);
//**** alterna cores de linhas numa tablegrid
var
iRow ,c: integer;
q, iCol: integer;
begin
c := Grid.RowCount - 1;
q := Grid.Columns.Count-1;
for iRow := 0 to c do
for iCol := 0 to q do
begin
if iRow mod 2 = 0 then Grid.Cell[iCol,iRow].Color := ColorEven
else
Grid.Cell[iCol,iRow].Color := ColorOdd;
end;
if ajusta then Grid.BestFitColumns(bfBoth); //ajusta conteúdo no tablegrid
end;