Hi,
as mentioned in the topic, how do I programmatically select a node?
With .NET's native treeview control, i can do something like treeview1.selectednode = node
Set UltraTreeNode.Selected to true
I have a followup question to this.
I set the datasource of the WinTree to a List of Objecte that have another List of the same type as a property (hierarchy). The tree is correctly initialized and I can navigate around.
The 'new' case is trivial and works as I can get the nodes that the user selected.
The edit-case on the other hand...
Using a simple but manual algorithm to find a node I finally found it in the hierarchy and set the Selected attribute to true.
Checking the tree.SelectedNodes.Count showed a '1' - so far so good. By the time I selected the node (After binding it to the data) it was not visible but on a tab page in the background. When I navigate to the correct page the selection is gone and the tree.SelectedNodes.Count is '0'.
(We are using 8.2)
Please advise how to solve that. Thanks
I've noticed some odd behavior of the DotNet BindingManager in the past when dealing with bound controls that are not initially visible, such as controls on a tab.
My guess is that the first time the tree paints, the CurrencyManager is positioning itself to the first row, which activates the first node in the tree and clears the selection.
If that's the case, and you don't care about the tree's ActiveNode being in synch with the CurrencyManager, then you could set SynchronizeWithCurrencyManager on the tree to false and that should fix it.
Of course, I'm really only guessing here, I could be wrong. In that case, maybe you could put a breakpoint in the tree's BeforeSelect event and see if the event is firing when the node is de-selected. If it does, you could take a look at the call stack to see what's causing it.