treeview node is highlighted even i did not right click on the node

后端 未结 4 539
孤独总比滥情好
孤独总比滥情好 2021-01-28 11:05

I am working on a winform and on my UI there is a treeview, I found that the treenode will be highlighted even I did not click on the node by right mouse (eg, Node1 will be high

4条回答
  •  一生所求
    2021-01-28 11:44

    try this

      void treeView1_MouseDown(object sender, MouseEventArgs e)
        {
    
    
            TreeViewHitTestInfo h = treeView1.HitTest(e.Location);
    
            if (h.Location != TreeViewHitTestLocations.Label && h.Location!= TreeViewHitTestLocations.None )
            {
                treeView1.SelectedNode = null;
            }
        }
    

提交回复
热议问题