procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect:TRect;DataCol: Integer; Column: TColumn; State: TGridDrawState);begin
  if Table1.FieldByName('Population').AsInteger > 20000000 then
      DBGrid1.Canvas.Font.Color := clBlue;  DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end

解决方案 »

  1.   

    const Rect: TRect; Field: TField; State: TGridDrawState);begin
      if Table1.FieldByName('Size').AsFloat > 10 then
        DBGrid1.Canvas.Font.Color := clRed;
      DBGrid1.DefaultDrawDataCell(Rect, Field, State);
    end;
      

  2.   

    首先将DBgrid的DefaultDrawing属性设置为false; 
    然后在DBBrid的DrawColumnCell事件中这样做: 
     
    procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; 
      DataCol: Integer; Column: TColumn; State: TGridDrawState); 
    begin 
      if Column.Field.AsInteger < 75 then begin 
         DBGrid1.Canvas.Font.Color := clWhite; 
         DBGrid1.Canvas.Brush.Color := clRed;  //这里设置单元格填充色 
         DBGrid1.Canvas.FillRect(Rect);   //这里对相应的单元格进行北景色填充 
      end; 
      //输出内容 
      DBGrid1.Canvas.TextRect( Rect, Rect.Left, Rect.Top, Column.Field.AsString); 
    end;