在我的树形视图中选择一个子节点 [英] Selecting a child node in my treeview

查看:60
本文介绍了在我的树形视图中选择一个子节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在窗体中添加了一个treeview控件.在
treeview我添加了一个根节点和两个子节点.
我要做的是,当用户单击
时 这些子节点之一必须打开一个表单.

我该怎么做?请任何帮助
..

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
appriciated..

推荐答案

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;
            }
            else
            {
                grandTotal += Convert.ToInt32(node.Text);
            }
        }
        return grandTotal;
    }


希望对您有帮助


Hope It Will Help You


这篇关于在我的树形视图中选择一个子节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆