I have an Ultratree that is NOT bound to a datasource. I load the nodes recurrsively via nodes.add. When a node is selected, I allow the user to delete the data linked to the node. I delete the data in sql based on the key of the node and then I try to remove the node from the tree and make the parent node of the deleted node active. I have tried using
Ultratree1.Nodes.Remove(Ultratree1.ActiveNode)
It errs on this line saying the "The node cannot be removed because it does not belong to this collection."
I debug on this line at runtime and I verify that the ActiveNode key is in the ultratree1.nodes collection, so I am not sure why this will not tremove the node. What is the proper way to do this?
The line of code you have here is making the assumption that the active node is a root node and not a child node. In other words, you are telling the tree to remove a node from UltraTree1.Nodes, which is the root collection.
This will not work if the ActiveNode is a child node, because child nodes do not belong to the root collection.
The solution is very simple. Remove the node from the collection to which it belongs.You can do this using the Remove method on the node itself.
Ultratree1.ActiveNode.Remove()