How to change the color of the DataGrid in DElphi? Just like the same name control in .NET.
-------------------------------------------------- ----------------------
It seems to be writing code in the OnDrawDataCell event.
-------------------------------------------------- ----------------------
PRocedure TForm1.dbgridDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
Begin
if DBGrid2.DataSource.DataSet.RecNo mod 2=1 then
Begin
DBGrid2.Canvas.Font.Color := clBlue;
DBGrid2.Canvas.Brush.Color:=clyellow;
end
else begin
DBGrid2.Canvas.Font.Color := clred;
DBGrid2.Canvas.Brush.Color:= clGradientActiveCaption;
end;
DBGrid2.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;