Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
555
Select treenode programmatically
posted

In our application using the ultratree control we should be able not only to activate but select a treenode programmatically

I tried the simple snippet

treenode.Actived= true; >> ok

treenode.Selected = true; >> nok !

tree.ActiveNode.Selected = true; >> also nok ?


 

As if it where impossible to do it like this ???

 

Any idea

Thanks Kagel

 

  • 555
    posted

    Hi Georgi/Mike,

     

    thank that was already helpful:

    nod.Selected = true; does nothing (nod is still unselected)

    whereas tree.SelecteNode.AddRange(new List<UltraTreeNode>() {nod }); sets the specific nod.Selected = true;

     

    Best regards

    Kagel 

  • 469350
    Offline posted

    Hi,

    What do you mean by "nok?" What's actually wrong? Are you getting an error message? Or is the node just not selected? If the latter, then how do you know it's not selected? How are you checking to see if the node is selected or not?

  • 53790
    Suggested Answer
    posted

    Hello Kagel,

    To solve your task, you should add your node to SelectedNodes collection. For example:

                List<UltraTreeNode> listnode = new List<UltraTreeNode>();

                listnode.Add(node1);

                listnode.Add(node2);

                listnode.Add(node3);

                ultraTree1.SelectedNodes.AddRange(listnode, false);

    Let me know if you have any questions.