?
Solved

Extend / customise .Net c# treeview control

Posted on 2011-09-07
3
Medium Priority
?
525 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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