使用treeview时怎样对选中的一行设置颜色,我用如下的方法只能对选中的TEXT设置,请大家帮帮忙.
 with TreeView2.Canvas do
   begin
     if cdsSelected in State then
       Brush.Color := clYellow;  // 设置所选行背景色     NodeRect:=Node.DisplayRect(false);
     // backRect即为所选区域
     backRect := Rect(0, NodeRect.Top,1000,  NodeRect.Bottom);
     FillRect(backRect);
   end;
上述代码不能对整行设置颜色,为何怎样才可对整行设置?

解决方案 »

  1.   

    看见这一句了么?
     NodeRect:=Node.DisplayRect(false);
    把参数false改为True.就OK了。
      

  2.   

    在CustomDraw中寫﹕
    with TreeView2.Canvas do
       begin
         if cdsSelected in State then
         begin
           Brush.Color := clYellow;  // 设置所选行背景色
           Brush.Style := FBrushStyle;
           FillRect(ARect);
         end;
       end;
      

  3.   

    to: edge
        改为TRUE不行我试过了,??
    to:小别
       FBrushstyle是什么意思?编译不通过。
      

  4.   

    FBrushstyle,刷子风格Brush.Style 是什么就是什么
      

  5.   

    with TreeView2.Canvas do
       begin
         if cdsSelected in State then
         begin
           Brush.Color := clYellow;  // 设置所选行背景色
           Brush.Style := FBrushStyle;
           FillRect(ARect);
         end;
       end;
      

  6.   

    demo-customdraw
    我已看过无法达到我的目的,还有知道怎么做的吗?
    谢谢了。