I set the TopNode property on the a tree that I rebuild to get the tree to remember the state it was left before I rebuilt it. Setting the TopNode property seems to work almost all the time but every once in a while I will get the following exception described below.
"All parent nodes must be expanded when setting 'TopNode'."
Im confused as to why this error is throw. It seems to have a valid TopNode and that the node is expanded. Any insight would be much appreciated. Thank you!
Hello RichSee,
I wanted to know if you were able to solve your issue based on these suggestions or you still need help. Please let me know.
My guess is that the node you are assigning is a child node and one of it's ancestors is collapsed. It's not the node itself whose expanded state matters, it is all of the ancestor nodes.
So you could try ensuring that all of the ancestors of the node are expanded before you assign it as the TopNode:
UltraTreeNode parentNode = node.Parent; while (parentNode != null) { parentNode.Expanded = true; parentNode = parentNode.Parent; }
I tried this but was not able to reproduce the mentioned behavior. This does not seem to me like a known issue and it should definitely not be happening if the nodes are expanded. Could you please provide a small sample project with the scenario, which reproduces this issue, I will be glad to take a look at it and assist you further on that matter.