TreeView显示数据

 

1.添加默认节点

 

 private void Form1_Load(object sender, EventArgs e)
        {
            TreeNode tn = new TreeNode("默认节点");
            treeView1.Nodes.Add(tn);
            tn.Tag = "aaaaaaaaaaaaaaa";

        }

2.添加

 private void button1_Click(object sender, EventArgs e)
        {
            string txt = textBox1.Text;
            TreeNode tn = new TreeNode(txt);
            TreeNode tnn = treeView1.SelectedNode;
            tnn.Nodes.Add(tn);

        }

 

 

3.删除节点

 private void button1_Click(object sender, EventArgs e)
        {
            string txt = textBox1.Text;
            TreeNode tn = new TreeNode(txt);
            TreeNode tnn = treeView1.SelectedNode;
            tnn.Nodes.Add(tn);

        }

 

 

 

 

 

节点

 

posted on 2017-03-20 17:29  溜氓  阅读(347)  评论(0编辑  收藏  举报

导航