Alternate row colors in DBGrid


Alternate row colors in DBGrid


procedure TfrmInvoices.DBGrid1DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);

begin
 if not(gdSelected in State) then
    If ( (DBGrid1.DataSource.DataSet.RecNo  MOD 2) = 0 ) then
        TDbGrid(Sender).Canvas.Brush.Color:= $00FFEAD5;
   DBGrid1.DefaultDrawColumnCell (Rect, DataCol, Column, State);
end;

home