码迷,mamicode.com
首页 > Windows程序 > 详细

C#WinForm treeview控件 选中一个根节点为其添加子节点

时间:2016-10-15 13:46:01      阅读:327      评论:0      收藏:0      [点我收藏+]

标签:

1 UI

技术分享

 

 

2 代码

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Threading.Tasks;
 9 using System.Windows.Forms;
10 
11 namespace WindowsFormsApplication1
12 {
13     public partial class Form1 : Form
14     {
15         public Form1()
16         {
17             InitializeComponent();
18         }
19 
20         private void button1_Click(object sender, EventArgs e)
21         {
22             //控件:treeview1
23             //selectnodes选中的结点
24             //nodes结点
25             //add添加新的结点
26             //结点的名称为textbox2.text
27             treeView1.SelectedNode.Nodes.Add(textBox2.Text);
28         }
29     }
30 }

 

 

 

3 效果

技术分享

C#WinForm treeview控件 选中一个根节点为其添加子节点

标签:

原文地址:http://www.cnblogs.com/jinlingzi/p/5963137.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!