Set node state in a virtual tree

I have created a virtual tree with multiple node and I want to disable some of them. I've seen there's a States property of a node. Which is a property of a type TVirtualNodeStates so I've check what kind of states I can set and apparently TVirtualNodeStates is a set of TVirtualNodeState .

TVirtualNodeState can be set to vsDisabled so I guess this is what i need to disable a node in my virtual tree.

But I can't do that. This is what I actually tried:

lNode := myTree.addChild(nil);
lNode.States := vsDisabled;

And it gives me the error

incompatible types between TVirtualNodeStates and TVirtualNodeState

How can I disable a node then?


You could write Node.States := [vsDisabled]; , to make your code compilable. But this is not what you are supposed to do. There are node states that you must keep untouched and by the mentioned statement you would throw them away and set only the vsDisabled one. You wanted to write either:

Include(Node.States, vsDisabled);

or:

Node.States := Node.States + [vsDisabled];

Another option (that should be preferred) is setting the state by the IsDisabled property:

VirtualTree.IsDisabled[Node] := True;
链接地址: http://www.djcxy.com/p/35022.html

上一篇: 是否可以在VirtualStringTree中多次显示一个对象?

下一篇: 在虚拟树中设置节点状态