When loading from a standard adapter the key for each item in the tree is not set.
If there is no key the the following code will no work.
UltraTreeNode TreeNodeVar = this.ultraTree2.GetNodeByKey(Convert.ToString(var.ToString()));
{
TreeNodeVar.ParentNodesCollection.Remove(TreeNodeVar);
}
What step am i missing please ?
Thought about looping through tree and adding the key but cannot see where that would best be located, and there is probably an easier way , right?
Key here refers to the Key property of node. The tree can't get the key from the data, because it would not know which field in the data to use. And also, the keys of the nodes have to be unique across the entire tree.
So if you want to assign a key to the bound nodes, the best place to do this would be the InitializeDataNode event. You could generate a unique key based on your data and set the Key property of the node.