我要以弄一列的值为依据,其中有重复值,几行中,如果该值相同,那么显示一种颜色,其值改变,则显示另一种颜色,两种颜色交替使用,条件该怎么写.
我用的是DxDbgrid

解决方案 »

  1.   

    参考一下:在dxdbgrid中oncustomdrawcell事件写
     if  ASelected then afont.Color:=clred;          //选中的栏的字体设为红色
      scheck:=ANode.Values[dxDBGrid1status.Index];  //dxdbgrid1status为某一个指定字段
      if not VarIsNull(scheck) then
        if scheck = '1' then                       //这段为指定值的判定,如果为1把这一行定义为白颜色
                                
            AColor := clWhite
         else
            acolor:=clInfoBk;
      

  2.   

    在dbgrid的onDrawColumnCell 事件中
       with TDbgrid(sender) do
       begin
        if DataSource.DataSet.fields[0]=.. then //条件
          canvas.Brush.color:=$00E2F3EB 
       else if ...
          canvas.brush.color:=Clwhite;
       else if ....
        DefaultDrawColumnCell(rect,datacol,column,state);
        end;
    以上的
    DBGRID中的代码和你所说的控件也是相差无几,一样的道理,参考一下罢