TreeView for WinForms | ComponentOne
Node Operations / Search Nodes
In This Topic
    Search Nodes
    In This Topic

    TreeView enables you to search for the nodes matching the specified string. To search for a node in TreeView, you can use Search or SearchAll method of C1TreeView class. The Search method takes string as a value, searches for the nodes using depth-first search and returns the node containing the searched string. On the other hand, the SearchAll method allows searches and shows all nodes containing the specified string.

    The following image shows the searched node containing “Chai” as input string.

    Searching Nodes

    To search for the nodes containing the string you input, use the following code. In this example, we have taken a text box where you can provide a string to be searched on a button click.

    C#
    Copy Code
    private void Searchbutton_Click(object sender, EventArgs e)
    {
          c1TreeView1.Search(textBox1.Text);
    }