I have tried every solution mentioned on these forums, with multiple variations, and the active node is still not highlighted (with background color) when the tree is loaded.
I set the tree data source to a dataset and expanded everything, this all works great.
I then tried several variations of the below, but the node is never highlighted.
var node = ultraTree1.GetNodeByKey("5"); ultraTree1.SelectedNodes.Clear(); node.BringIntoView(); ultraTree1.ActiveNode = node; ultraTree1.HideSelection = false; node.Selected = true;
The active node is correct and loads my list view with the related data. Even trying to override the back color didn't work. When I manually select the node, it highlights properly.
Hello Sam,
I am attaching a sample project that I put together that demonstrates both routes. With the current implementation, if you just set the ActiveNode and set the node.Selected property to true, you should be able to call Focus() on the UltraTree and see it highlighted. This behavior is currently present in the sample.
If you instead want to see the recommendation I made above, you can comment out the “Focus()” method call and uncomment the two lines of code above in the constructor of the Form.
I hope this helps. Please let me know if you have any other questions or concerns on this matter.
UltraTreeActivationTest.zip
Thanks for the response, but that did not work. Is there an execution order that matters? I tried various ones but nothing changes.
Is there a way to set the tree to the focused control on the form? I tried ultraTree1.Focus() but that did not help.
With the default implementation of the UltraTree, the tree needs to be the focused control to be able to see the active / selected node. You can override this by setting the following though:
this.ultraTree1.Override.ActiveNodeAppearance.BackColor = SystemColors.Highlight; this.ultraTree1.Override.ActiveNodeAppearance.ForeColor = Color.White;
Please let me know if you have any other questions or concerns on this matter.