在一个DBGRID 里面有两个同样的记录,怎么使一条的字体为黑字,一条为红字。

解决方案 »

  1.   

    var
      pubText:string; procedure TqFmAbnOrder.DBGrid1DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumn;
      State: TGridDrawState);
      var
       AText:String;
    begin
      AText:=Column.Field.AsString;
      If AText=pubText then
      begin  
        DBGrid1.Canvas.Font.Color:=clRed;
        DBGrid1.Canvas.Font.Style:=[fsBold];
        DBGrid1.Canvas.TextRect(Rect,Rect.Left+2,Rect.Top+
        (Rect.Bottom-Rect.Top-DBGrid1.Canvas.TextHeight(AText)) div  2,AText);
      end;
      pubText := AText;
     end;
    end;
      

  2.   

    你要做退货还是冲消?上面的方法就可以,别忘记reflash一下。