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
iRow ,c: integer;
q, iCol: integer;
c := Grid.RowCount - 1;
q := Grid.Columns.Count-1;
for iRow := 0 to c do
for iCol := 0 to q do
if iRow mod 2 = 0 then Grid.Cell[iCol,iRow].Color := ColorEven
Grid.Cell[iCol,iRow].Color := ColorOdd;
if ajusta then Grid.BestFitColumns(bfBoth); //ajusta conteúdo no tablegrid