procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
with TDBGrid(Sender) do
begin
case Self.ADOQuery1.RecNo Mod 2 of
0: Canvas.Brush.Color :=clMoneyGreen;
1: Canvas.Brush.Color :=clWindow;
end;
if gdSelected in State then //这个是改变被选择行的高亮颜色
begin
Canvas.Font.Color :=clBackground;
Canvas.Brush.Color:=clSkyBlue;
Canvas.FillRect(Rect);
end;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
with TDBGrid(Sender) do
begin
case Self.ADOQuery1.RecNo Mod 2 of
0: Canvas.Brush.Color :=clMoneyGreen;
1: Canvas.Brush.Color :=clWindow;
end;
if gdSelected in State then //这个是改变被选择行的高亮颜色
begin
Canvas.Font.Color :=clBackground;
Canvas.Brush.Color:=clSkyBlue;
Canvas.FillRect(Rect);
end;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;