Link to home
Start Free TrialLog in
Avatar of apuma
apumaFlag for United States of America

asked on

How to Add a panel subClass to designer

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
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of apuma

ASKER

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)
Avatar of Nasir Razzaq
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.
Avatar of apuma

ASKER

I think the build is failing to create the controls because there are other errors.

I will clean the other errors and try again
Good idea :-)
The Toolbox always reference compiled assembly, not your source code. Until the application compile, you won't see the controls in the Toolbox.
Avatar of apuma

ASKER

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.