Searching a TreeView

2 posts, 0 answers
  1. Christian
    Christian avatar
    81 posts
    Member since:
    Aug 2008

    Posted 21 Oct 2008 Link to this post

    Hi,
    I would like to look in a complex treeview for a node with a certain name. How can I go through all nodes independently of the level?
    For a reference I would be grateful.
    Thanks.
    Christian
  2. Nick
    Admin
    Nick avatar
    767 posts

    Posted 21 Oct 2008 Link to this post

    Hi Christian,

    Thank you for your question.

    Please review the following code:

    private void radButton1_Click(object sender, EventArgs e)  
    {  
                recursiveTreeTraversal(radTreeView1.Nodes);  
    }  
     
    private void recursiveTreeTraversal(RadTreeNodeCollection levelNodes) {  
     
                foreach (RadTreeNode node in levelNodes) {  
                     if (node.Text == "something") {   
                           
                         //some code here;  
                             
                         //...  
                         break;}    
                    recursiveTreeTraversal(node.Nodes);  
     
                }  


    Do not hesitate to contact me if you have further questions.

    Sincerely yours,
    Nick
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top