十天前问的一个问题,竟没一个人回答
在cxgrid中怎样实现以下效果
 if query1.FieldByName('all').asstring>40 then
        begin
                dbgrid1.Canvas.Font.Color:=clred;
                dbgrid1.Canvas.Brush.color:=clyellow;
        end
        else
        begin
                dbgrid1.Canvas.Font.Color:=clblue;
                dbgrid1.Canvas.Brush.color:=clyellow;
                end;
 
        dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);

解决方案 »

  1.   

    具体一点行不,CXGRID是什么呀
      

  2.   

    倒.
    好久没来Delphi论坛了. 
    看过这个仁兄的代码. 真有点失望...
    ----if query1.FieldByName('all').asstring>40 then---
    这句中一个是asString(string类型). 而40是Integer类型 , 这两个相比. 在Delphi里绝对是低级错误.
      

  3.   

    cxGrid是外部控件,不能说中国没高手,而是我们一般不会去用那些外部控件,所以帮不了你
      

  4.   

    楼主,你不觉得CXGRID控件太宠大了吗?
    用了之后你的应用程序会很大的。少用第三方控件。我有一个同事,QQ名叫“饮天”
    他用过。
    你自己找吧。
      

  5.   

    cxGrid是比较麻烦,等我学会了我告诉你,呵呵.........我们的软件里全部使用cxGrid,难啊................
      

  6.   

    devexpress的那个格吧,是很复杂的格哦。
      

  7.   

    对了你可以到devexpress的新文组问问,就在devexpress主页上找找我去过的。
    因为那个格太复杂,我们用也只是用一点功能。
      

  8.   

    cxGrid是可以实现此功能的,但具体怎样实现我还不知道,
    不过它的例子中有实现此功能的例子的,只是比较复杂,我就没有去研究了
      

  9.   

    你看一下\Developer Express Inc\ExpressQuantumGrid 4\Delphi 7\Demos\CustomDrawTableViewDemo.exe这个例子,它就实现了
      

  10.   

    query1.FieldByName('all').asstring>40 确实不好实现,让俺想想……
      

  11.   

    很简单的搞定(刚看了此贴后研究CXGRID的DEMO搞定的)
    procedure TFm_Rkcx.GD_RkcxBTCustomDrawCell(Sender: TcxCustomGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
      var ADone: Boolean);
    var ATextToDraw:String;
        ARec: TRect;
    begin
      ATextToDraw := AViewInfo.GridRecord.DisplayTexts[AViewInfo.Item.Index];
      ARec := AViewInfo.Bounds;
      if AViewInfo.GridRecord.Values[6]<1000 then
        ACanvas.Canvas.Font.Color := clRed;
      ACanvas.Canvas.FillRect(ARec);
    end;
      

  12.   

    你自己改一下if AViewInfo.GridRecord.Values[6]<1000 then
    就行了                                     *  ****
      

  13.   

    谢谢belllab(bell)的回答,问题解决了,也谢谢各位的参与
    结贴。
      

  14.   

    query1.FieldByName('all').asstring>40