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); }
节点