IS there a way to alternate backgoundcolor


Is there a way to alternate backgroundcolor for items in grid?

Something like

if (((ARow mod 2) = 0)) then
    GridItems.CellProperties[ACol, ARow].BrushColor := clSilver
   GridItems.CellProperties[ACol, ARow].BrushColor := clWindow;

I have done this on DrawCell event, but grid keeps redrawing.

Thanks in advance,

Omar Zelaya


Actually is Row BackColor for each item.

Thanks in advance,

Omar Zelaya

Hi Omar,

in order to chenge color (text or background) try with

procedure TForm2.SG1GetCellColor(Sender: TObject; ARow, ACol: Integer;

AState: TGridDrawState; ABrush: TBrush; AFont: TFont);


if odd(Arow) Then Abrush.Color:=clRed




Put your logic in order to get the rigth color.



I want in a dbADVgrid color cells depending on the value of record value of the selected row.
The color change only happens when I click the row wich holds the right value, but only the row I left, wich not has the right value is colered. when I move to the next row wich has the right value all rows are colered, also wich do not have the correct value.

You can use the grid.Bands.Active property.  You can set the band colours via grid.Bands.PrimaryColor and grid.Bands.SecondaryColor according to the TMS docs.

My previous post relates to the original question by the way.