I have a TAdvTreeView named TV, using virutal nodes, with 4 nodes. all of them have children.
I want to expand the last node (Node with index 3) and want the rest to stay collapsed.
I have this code:
TV.BeginUpdate;
TV.ClearNodes;
TV.EndUpdate;
TV.Refresh;
TV.ExpandVirtualNode(TV.GetRootVirtualNodeByIndex(3),True);
Why doesn't this work?
When I use TV.ExpandAll it does work, but that's not what I want.
I use GetNumberOfNodes and GetNodeText to fill the tree.
Why are you clearing the nodes? If there are no nodes, you cannot expand/collapse. If you want to expand a specific node, please use the following code:
AdvTreeView1.ExpandNode(AdvTreeView1.Nodes[2]);
I use virtual nodes as I stated, so that won't work.
The main problem is that virtual nodes are much faster than collection based nodes, but it is not explained in the manual very well. So I started with what I could find: I use GetNumberOfNodes and GetNodeText to fill the tree.
I then had to clear the existing example tree and trigger the new virtual tree. I did this like this;
TV.BeginUpdate;
TV.ClearNodes;
TV.EndUpdate;
TV.Refresh;
This cleares exisiting nodes and triggers a redraw, so the Virtual Nodes are added.
That works well, but I have not been able to expand RootNode 3 because whereeven I place this code, it won't work, it always stays collapsed:
TV.ExpandVirtualNode(TV.GetRootVirtualNodeByIndex(3),True);
Hi,
As you are using a complete virtual node structure, you need to return a boolean in the OnIsNodeExpanded event. This event determines if the node is expanded. So calling the ExpandVirtualNode functionality only works if you are return a true in this event. Virtual nodes are completely based on user input via events.
Of course. How simple can it be :-)
Thank you.