I
I
Ingvar Von Bjork2016-05-22 20:10:13
C++ / C#
Ingvar Von Bjork, 2016-05-22 20:10:13

How to find all nodes of a treeView?

Can't get all treeView nodes. When executing the following code, only the first node's Text is displayed endlessly:

private void Button_Click(object sender, EventArgs e)
{
    if (searchOnAll.Checked == true)
    {
        TreeNodeCollection nodes = themes.Nodes;
        foreach (TreeNode tn in nodes)
        {
            CallAllNodes(tn);
        }
    }
}
 
private void CallAllNodes(TreeNode node)
{
    MessageBox.Show(node.Text);
    foreach (TreeNode tn in themes.Nodes)
    {
        CallAllNodes(tn);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ingvar Von Björk, 2016-05-22
@DeboshiR

foreach (TreeNode tn in node.Nodes)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question