Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


C# WinForms: Disabling the Collapse on a double-click for TreeView

Posted on 2012-09-15
Medium Priority
Last Modified: 2012-09-15
I coded the double-click event to edit the node double-clicked on.  So I no longer want the default behavior which collapses the node tree for the Node double-clicked on.

How do I stop this?

Question by:newbieweb
LVL 40

Accepted Solution

Jacques Bourgeois (James Burger) earned 2000 total points
ID: 38401867
Create your own TreeView by inheriting from the standard one:
Public Class YourTreeView
	Inherits System.Windows.Forms.TreeView

	Protected Overrides Sub OnNodeMouseDoubleClick(e As TreeNodeMouseClickEventArgs)
		'Your alternate code
	End Sub

End Class

Open in new window

Inheritance lets you inherit all the functionnality of the standard TreeView. But since you overrides the method that triggers NodeMouseDoubleClick, you are the one in control on that event.

Compile your code, and your custom TreeView should appear in an extra tab at the top of the ToolBox. Use it anywhere you want in place of the standard TreeView. No need to code the thing in the application, it is now part of your new "enhanced" TreeView.

Author Closing Comment

ID: 38401938
Thanks.  Good idea...

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Loops Section Overview

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question