在这个事件DrawColumnCell写下面的代码
procedure Tbaseinputfrm.DBGridTopDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
var
RectTemp : TRect;
begin
inherited;
with DBGridTop do
begin
if State <> [gdSelected, gdFocused] then
begin
if (AdoQinput.RecNo mod 2)=0 then
Canvas.Brush.Color := rgb(239,247,255)
else
Canvas.Brush.Color := rgb(222,237,252);
end;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
if gdSelected in state then
begin
RectTemp := Rect;
Canvas.Brush.Color:=RGB(160,191,223);
Canvas.Font.Color := ClBlack;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
Canvas.Brush.Color := RGB(0,0,0);
Canvas.FrameRect(RectTemp);
end;
end;
end;