if column.field.asinter .... then begin Dbgrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State); Dbgrid1.Canvas.Brush.Color:=tempColor; Dbgrid1.Canvas.Font.Color:=tempColor2; end
在dbgrid的DrawColumnCell事件中写,以下是范例 procedure TForm1.Dbgrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if Dbgrid1.datasource.dataset.FieldByName('Urgent').AsString='Y' then begin Dbgrid1.Canvas.Font.Color:=clred; end; Dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state); end;
begin
Dbgrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
Dbgrid1.Canvas.Brush.Color:=tempColor;
Dbgrid1.Canvas.Font.Color:=tempColor2;
end
procedure TForm1.Dbgrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if Dbgrid1.datasource.dataset.FieldByName('Urgent').AsString='Y' then
begin
Dbgrid1.Canvas.Font.Color:=clred;
end;
Dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
end;