解决treeview未选中时,默认选中首个根节点的问题!

 1 private void treeView1_MouseUp(object sender, MouseEventArgs e)

 2         {

 3              

 4             TreeNode selectnode = this.treeView1.GetNodeAt(e.Location);

 5             if (selectnode == null)

 6             {

 7                 this.treeView1.SelectedNode = null;

 8  

 9             }  

10  

11         }

12  

13         private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)

14         {

15             if (e.Action == TreeViewAction.Unknown)

16                 e.Cancel = true;

17         }

 

你可能感兴趣的:(treeview)