//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//source for main form :
//...
uses
// ...
Grids, DBGrids, db
//...
procedure artgrid(Sender: TObject; const Rect: TRect; DataCol: Integer;
Column: TColumn; State: TGridDrawState);
//...
implementation
//...
procedure TForm1.artgrid(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if ((Sender as tdbgrid).DataSource.DataSet.RecNo mod 2) = 0 then
(Sender as tdbgrid).Canvas.Brush.Color := clblue; //or any color
(Sender as tdbgrid).DefaultDrawColumnCell(rect, datacol, column, state);
end;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// for all DrawColumnCell event of DBGrid in any Form (here "Form2"):
procedure TForm2.DBGrid2DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
Form1.artgrid(Sender, Rect, DataCol, Column, State);
end;
|