呵呵,试试这个,也许有点用
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if DBGrid1.DataSource.DataSet.RecNo mod 2=0 then
begin
DBGrid1.Canvas.Brush.Color :=clWhite ;
DBGrid1.Canvas.FillRect(Rect);
DBGrid1.Canvas.Font.Color :=clBlack;
end
else
begin
DBGrid1.Canvas.Brush.Color :=clBlue ;
DBGrid1.Canvas.FillRect(Rect);
DBGrid1.Canvas.Font.Color :=clBlack;
end;
if gdSelected in State then
begin
DBGrid1.Canvas.Brush.Color :=clRed ;
DBGrid1.Canvas.FillRect(Rect);
DBGrid1.Canvas.Font.Color :=clBlack;
end;
DBGrid1.DefaultDrawDataCell(Rect, Field, State);
end;