delphi - Disable and change color of node in Treeview -
i looking way of disabling proper nodes.
let's have created simple treeview structure below:
- parent 1 (disable)
- parent 2
- child 1
- child 2 (disable)
so far have found workaround how that, still doesn't work @ all. use onchanging
event handler:
procedure tform1.treeviewchanging(sender: tobject; node: ttreenode; var allowchange: boolean); begin if (node.text = 'parent 1') or (node.text = 'child 1') allowchange := false; end;
it works, because can't click on node, issue after 'disabling' node way, color of parent 1
, child 1
nodes same other. way change color of nodes (grey)? or maybe know way disabling nodes in ttreeview component?
to disable node, set enabled
property false
. disabled item displayed in gray color.
to change normal color of nodes text, change ttreeview.font.color
.
to change color of disabled nodes text, use oncustomdrawitem
event:
procedure tform2.treeview1customdrawitem(sender: tcustomtreeview; node: ttreenode; state: tcustomdrawstate; var defaultdraw: boolean); begin if cdsdisabled in state sender.canvas.font.color := clred; //cl3dlight; end;
default color settings:
disabled color = cl3dlight
:
normal text color = clgreen
, disabled color = clred
:
Comments
Post a Comment