?
Solved

How to Add a panel subClass to designer

Posted on 2011-09-12
7
Medium Priority
?
785 Views
Last Modified: 2012-05-12
Hello Experts.

I want to create a custom panel control and use it in the designer.

so my custom panel looks like this
Public Class pnlAttribs
    Inherits System.Windows.Forms.Panel

    '' custom properties and methods go here

end Class

Open in new window


but i cannot locate it in the choose toolbox items dialog (even after building) to add it to my toolbox and get it into the designer, i assume it is not producing the .dll that VS is looking for.  (modification to the declarations in the designer files makes visual studio very angry)

I do not know if i need to inherit a usercontrol object instead of panel but i would like to have all the features of the panel available to the subclass.

I suppose i could create a user control that contains a panel but that seems to be an unnecessary layer  i.e.
Public Class pnlAttribs
 inherits UserControl

 friend withEvents myPanel = new panel

  '' custom properties and methods go here

end class

Open in new window


if someone could tell me how to get an inheritec panel into the toolbox i would be very gratefull

Thanks,
Anthony

ps. i am using
Microsoft Visual Studio 2008
Version 9.0.21022.8 RTM
Microsoft .NET Framework
Version 3.5 SP1

Installed Edition: Standard

Microsoft Visual Basic 2008   91851-136-7108014-60754
Microsoft Visual Basic 2008
0
Comment
Question by:apuma
[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
  • 2
  • 2
7 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 2000 total points
ID: 36525650
A UserControl is useful to build a control out of a group of other controls, not to build a standalone control. Inheriting from Panel is the way to go.

If your Panel class is defined in the application itself, you will see it automatically at the top of the ToolBox.

If it is in a dll, then its appearance in the Toolbox depends on 2 things. The second one is probably the one that interests you, but so that you get the whole thing about the concept...

If your application references the compiled dll, the way it references other dlls, you need to manually add your control to the Toolbox, through a right click... Choose items... Browse to your dll. This is usually not a very good way to work for your own controls, because of versioning problems that forces you to refresh this thing regularly if you want to see changes made to your dll.

What follows is good for testing purposes or when you work alone. It is usually not a good suggestion if you work with a team.

For your own controls, it is better to add your dll in each solution where you want to use it, along with the application. Instead of making the reference through the .NET tab of the reference window, do it through the Project tab. This will make a reference to the source code, so any change you make to the source code of the control will automatically be visible in the application.

And you will gain something you want. Because it is part of the solution, it will automatically appear at the top of the Toolbox.
0
 
LVL 1

Author Comment

by:apuma
ID: 36525709
Thank you JamesBurger

the Panel class is defined within the project  (project .. add class.. then mark the class as inheriting panel)  so the vb file created is sitting in my project explorer, however the panel is not sitting in my designer toolbox (under $projectName Components)

I have been tinkering and created a user control as well and that is not showing in the toolbox either.  (there are errors currently in the application that stops it from running, but i assume the error free files such as the custom control and inherited panel would build and become available [as they are needed to fix the errors])

I want to avoid creating the control outside of this project, as it is only used in this project  (also i am the only developer working on the project)
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36526177
Usually when you have custom controls in your project, these controls appear automatically at the top of toolbox when you build the project. Build the project and then show us a screenshot of the toolbox.
0
Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

 
LVL 1

Author Comment

by:apuma
ID: 36526235
I think the build is failing to create the controls because there are other errors.

I will clean the other errors and try again
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36526246
Good idea :-)
0
 
LVL 40
ID: 36526456
The Toolbox always reference compiled assembly, not your source code. Until the application compile, you won't see the controls in the Toolbox.
0
 
LVL 1

Author Comment

by:apuma
ID: 36712402
After the long process of getting the application building properly i now see the control in the toolbox list as JamesBurger originally stated.  I had to do a bit of fiddling with serialization in order for the custom properties to show in the designer.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
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…
Suggested Courses

764 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