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:
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;
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.