1. 程式人生 > >如何改變DBGridEh中其中某個單元格的字型顏色

如何改變DBGridEh中其中某個單元格的字型顏色

procedure TFormMain.DbgAllDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumnEh;
  State: TGridDrawState);
begin
  if (Column.FieldName='1|規格') and
     (DbgAll.DataSource.DataSet.FieldByName('1|規格').AsString='關機') then
      DbgAll.Canvas.Font.color:=clred;
      DbgAll.DefaultDrawColumnCell (Rect, DataCol, Column, State);
  end;
end;