日期:2014-05-18 浏览次数:20781 次
private void Form1_Load(object sender, EventArgs e) { this.treeView1.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseDoubleClick); this.treeView1.Nodes.Add("root1"); this.treeView1.Nodes.Add("root2"); this.treeView1.Nodes.Add("root3"); } static int i = 0; private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { e.Node.Nodes.Add("son"+i.ToString()); i++; }
------解决方案--------------------
private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
e.Node.Nodes.Add("son"+i.ToString());
}
------解决方案--------------------
先增加一根节点,注册 NodeMouseDoubleClick 节点双击事件,事件方法参数 e.Node 是点击的那个节点,e.Node.Nodes.Add 添加子节点
------解决方案--------------------