Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I added a treeview control to my form. In the
treeview I added a Root Node and two child nodes.
What I want to do is when I the users clicks on
one of those child nodes it must open a form.

How would I do this? Please any help would be

1 solution

private void button2_Click(object sender, EventArgs e)
        int grandTotal = CalculateNodes(this.treeView1.Nodes);
    private int CalculateNodes(TreeNodeCollection nodes)
        int grandTotal = 0;
        foreach (TreeNode node in nodes)
            if (node.Nodes.Count > 0)
                int childTotal = CalculateNodes(node.Nodes);
                node.Text = childTotal.ToString();
                grandTotal += childTotal;
                grandTotal += Convert.ToInt32(node.Text);
        return grandTotal;

Hope It Will Help You
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900