custom NodeMouseDoubleClick event  
Author Message
INTPnerd





PostPosted: .NET Compact Framework, custom NodeMouseDoubleClick event Top

I need a node double click event for TreeView.  I used this tutorial and modified it to add a node double click event as well:
http://www.hide-link.com/

I added this to the TreeViewBonus class:
public event TreeNodeMouseClickEventHandler NodeMouseDoubleClick;
protected void OnNodeMouseDoubleClick(TreeNodeMouseClickEventArgs e)
{
            if (NodeMouseDoubleClick != null)
                NodeMouseDoubleClick(this, e);
}

I also changed the OnNodeMouseClick method to test for a double click:
protected void OnNodeMouseClick(TreeNodeMouseClickEventArgs e)
        {
            if (_prevClickNode != null && _prevClickTimeSet && e.Node == _prevClickNode)
            {
                TimeSpan elapsedTime = DateTime.Now - _prevClickTime;
                if (elapsedTime.TotalMilliseconds <= SystemInformation.DoubleClickTime)
                {
                    OnNodeMouseDoubleClick(e);
                }
            }
            if (NodeMouseClick != null)
                NodeMouseClick(this, e);

            _prevClickTimeSet = true;
            _prevClickNode = e.Node;
            _prevClickTime = DateTime.Now;
        }

By defualt a TreeView will expand a node when it is double clicked.  The problem is that when a node is double clicked, the OnNodeMouseClick method is only called once, but I don't know why.  Any help will be greatly appreciated!



Smart Device Development12  
 
 
AlexY





PostPosted: .NET Compact Framework, custom NodeMouseDoubleClick event Top

In the WM_Notify_Handler method, you can try to add hadling with the NM_DBLCLK message.

const NM_DBLCLK = (NMFIRST-2);

and raise your your NodeMouseDoubleClicked event.


 
 
INTPnerd





PostPosted: .NET Compact Framework, custom NodeMouseDoubleClick event Top

thanks AlexY! that worked perfectly! in the WM_Notify_Handler method I added an additional case for Win32.NM_DBLCLK and used most of the same code from the previous case.