Solved

Extend / customise .Net c# treeview control

Posted on 2011-09-07
3
499 Views
Last Modified: 2012-06-27
I am working with a Windows Forms c# aplication using Visual Studio 2010 and .Net 4.  I currenlty have a TreeView control on multiple forms I use to present a list of custom ProductCategories.  In these forms I have methods to populate the TreeView as required.  Instead I would like a custom TreeView control normal in all respects but which would a list of these ProductCategories in the constructor and display it properly.  How can I do this?
0
Comment
Question by:canuckconsulting
3 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 36495086
0
 

Author Comment

by:canuckconsulting
ID: 36495678
I was hoping to just inherit from the standard control and just add a new constructor to it. I'm just not sure how to do it!
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 36500476
Inheritance is effectively the best way. Here is the syntax:

class ProductCategTreeView : System.Windows.Forms.TreeView
{
    public ProductCategTreeView()      
   {
       // Do your stuff
   }
}

Compile once and you will see your new TreeView in a new tab at the top of the Toolbox. Use as you please.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MediaHelp 4 23
Database Connections Not being returned to Connection Pool 7 26
parsing JSON help 1 9
Formula for calculating ROI on training 6 25
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

778 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