Treelist颜色显示问题:现Treelist数据如下:
ID Name sex
1, a    aa 
2, b    bb
3,c    cc
我想把Treelist中ID=3 的记录用红色表示,代码如下
procedure TFrmZwCollSurv.zwcxTreeList1CustomDrawCell(Sender: TObject;
  ACanvas: TcxCanvas; AViewInfo: TcxTreeListEditCellViewInfo;
  var ADone: Boolean);
begin
  inherited;
      zwcxTreeList1.Canvas.Font.Color := clRed;
end;
但是结果却是全部都成红色了,改了好长时间没有改好,请大虾们帮忙···多谢多谢···

解决方案 »

  1.   

    知道treeView,知道listView,但不知道你这个Treelist是那个组件。
      

  2.   

    楼主说一下这是哪里的控件,没用过,
    treeview也没有这样的事件
      

  3.   

    不过更具楼主说的事件Drawcell 这应该是Grid的子类
    你应该在Drawcell事件里写这样的代码:
    if zwcxTreeList1.Cells[0,ARow]='3' then  
    begin
      zwcxTreeList1.Canvas.Font.Color := clRed;
      zwcxTreeList1.canvas.TextRect(Rect,Rect.left,Rect.top,zwcxTreeList1.cells[Acol,Arow]);
    end;
      

  4.   

    procedure TFrmZwCollSurv.zwcxTreeList1CustomDrawCell(Sender: TObject;
      ACanvas: TcxCanvas; AViewInfo: TcxTreeListEditCellViewInfo;
      var ADone: Boolean);
    begin
      inherited;
      if AviewInfo.node.value[0] = 3 then
        ACanvas.Brush.Color := clred;
    end;
      

  5.   

    呵呵,楼上正确, 我真是笨, 何必管他什么控件呢, 看事件中的参数就知道用Acanvas来设置背景和字体颜色了 呵呵!