Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Extend / customise .Net c# treeview control

Posted on 2011-09-07
3
Medium Priority
?
535 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

596 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