在oncoulmncell事件里控制 if dm.q_lingsh.fieldbyname('cx').asboolean=true then
   dbgrid1.canvas.font.color:=clred;

解决方案 »

  1.   

    我在dbgrid1的drawcolumncell中,没错呀
      

  2.   

    你跟踪一下你的AsBoolean吧,Delphi的这个有点问题。
      

  3.   

    Canvas.Font.Color := clRed;
    DefaultDrawDataCell(Rect, Field, State);
      

  4.   

    [procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
      Field: TField; State: TGridDrawState);
    begin
        if Table1.FieldByName('Salary').AsInteger > 30000 then begin
            //字体
            DBGrid1.Canvas.Font.Color := clRed;//字体色
            //背景        
            DBGrid1.Canvas.Brush.Color := clBlue;//背景色
            DBGrid1.Canvas.FillRect(Rect);
        end;
        DBGrid1.DefaultDrawDataCell(Rect, Field, State);
    end;
      

  5.   

    procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    var
      Value:String;
    begin
      if ADOTable1.FieldByName('qty').AsInteger>10 then
      begin
        Value:=ADOTable1.FieldByName('qty').AsString ;
        DBGrid1.Canvas.Font.Color := clRed;
        DBGrid1.Canvas.Brush.Color :=clBlue;
        DBGrid1.Canvas.Pen.Color   :=clBlue;
        DBGrid1.Canvas.FillRect(Rect);
        DBGrid1.DefaultDrawDataCell(Rect, 
                   ADOTable1.FieldByName('qty'),  State);
      end;end;