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);
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!
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.