您的当前位置:首页正文

设置TreeView中每个节点的颜色

2024-11-11 来源:个人技术集锦
procedure TForm1.TreeView1CustomDrawItem(Sender: TCustomTreeView;
  Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
    if Node.Text ='Red' then
    begin
        Sender.Canvas.Brush.Color := clREd;
    end;
    if Node.Text ='Blue' then
    begin
        Sender.Canvas.Brush.Color := clBlue;
    end;
    if Node.Text ='Green' then
    begin
        Sender.Canvas.Brush.Color := clGreen;
    end;
end;

转载于:https://www.cnblogs.com/tecsoon/archive/2009/03/27/1423683.html

Top