locked
set a treeview selected based on a query string. RRS feed

  • Question

  • User122680042 posted

    Hi I have a webform. On the left hand side I have a tree navigation . It is populated from a XML file with .
    What I want to achive is when a querystring of the value of the XML file is matched , the tree node sets a setfocus or highlights on a particular node from the querystring passed through. I cant find a method which mimmicks findtreenode with value x and sets a selected .


    e.g treenode is filled

    home
    |
    folder 1
    |    -- item 1
    |    -- item 2
    |
    folder 2
    |    -- item 3
    |    -- item 4


    when a querystring of SC=Item 1 is passed , it should search against the tree and open the folder branch and select item Item 1

    I can use a for next loop and loop through each node but it will get slower as more nodes are added.

    Monday, June 21, 2010 12:32 PM

Answers

  • User-624088818 posted

    Try below code

    TreeNode node=TreeView.FindNode("ParentNode\\ChildNode");

    node.select();


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 23, 2010 7:20 AM
  • User-1136466523 posted

    Hi,

    >>I can use a for next loop and loop through each node but it will get slower as more nodes are added.

    No matter which practice you use, it can't avoid an underlying loop. I just wonder how you populate the treeview, if you perform it manually, you can give a check for each node in binding phase, instead of having a loop again after the treeview bound.

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 23, 2010 11:26 PM

All replies

  • User-624088818 posted

    Try below code

    TreeNode node=TreeView.FindNode("ParentNode\\ChildNode");

    node.select();


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 23, 2010 7:20 AM
  • User-1136466523 posted

    Hi,

    >>I can use a for next loop and loop through each node but it will get slower as more nodes are added.

    No matter which practice you use, it can't avoid an underlying loop. I just wonder how you populate the treeview, if you perform it manually, you can give a check for each node in binding phase, instead of having a loop again after the treeview bound.

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 23, 2010 11:26 PM