再贴一次,呵呵。
procedure TForm1.DBGridDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
{
if Query1.FieldByName('Col1').AsString <> '' then
if (gdSelected in State) and (DBGrid1.Focused = True) then
DBGrid1.Canvas.Font.Color := clWhite
else
DBGrid1.Canvas.Font.Color := clTeal;
}
if query1.FieldByName('Col1').AsString <> '' then
dbgrid1.Canvas.Brush.Color := $00E0FFFF
else
dbgrid1.Canvas.Brush.Color := clWhite;
if ((gdSelected in State) and (gdFocused in State)) then
begin
dbgrid1.Canvas.Brush.Color := clNavy;
dbgrid1.Canvas.Font.Color := clWhite;
end;
dbgrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;