开发者

Stop toggle in treenode in winforms

开发者 https://www.devze.com 2023-03-09 19:33 出处:网络
i have a treeview in winforms . When i double click on treenode ,its childnode gets disappear .Again when i click on th开发者_JAVA百科at very node its child nodes gets expand. Any body please help me

i have a treeview in winforms . When i double click on treenode ,its childnode gets disappear .Again when i click on th开发者_JAVA百科at very node its child nodes gets expand. Any body please help me out.


If you want to disable double click alltogether you will have handle directly the WM_LBUTTONDBLCLK (0x0203). To do that create a MyTreeView control inheriting from System.Windows.Forms.TreeView and override the WndProc(ref Message m) method.

 public class MyTreeView : TreeView
{
    protected override void WndProc(ref Message m)
    {
        if (m.Msg == 0x203) { m.Result = IntPtr.Zero; } //Makes the control ignore double licks`
        else base.WndProc(ref m);
    }              
};

This solution will disable completely double clicks on all the TreeView control. If you can live with that, this solution will do.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号