Solved

Extend / customise .Net c# treeview control

Posted on 2011-09-07
3
494 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now