ury

Hi,

I want to create my own custom control based on the existing Panel class (I'm using panel just as an example for a container control).

The UserControl automatically created by VS in the new project has a neat designer on which I can place other controls (buttons, checkboxes e.g.).

When I change the custom control's base class from UserControl to Panel, the neat designer disappears and I get a "hardly-visual" editor where most of the visual design features (such as positioning and resizing the controls) are unavailable.

Is this the way things are if I want to design a custom panel or am I missing something

Thanks in advance,

Ury



Re: .NET Base Class Library Custom panel vs. UserControl

MarcD

The deesigner is an attribute that is called Designer("...........")]

If you are using Visual studio 2005 and right click on a Microsoft .NET Control definition e.g.

public class MyTool : UserControl (right clicking on UserControl) and choosing "Go to Definition it should take you to a page that is labeled MetaData.

Expand the little section right befor ethe class definition.

Then see what attributes are there. You may be able to try copying the Designer attributes over to your control and then change the base class to the class you awant.

.





Re: .NET Base Class Library Custom panel vs. UserControl

ury

Thanks for the response.

I have acted accoring the above, which resulted in the following code:

Code Snippet

[Designer("System.Windows.Forms.Design.PanelDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]

public partial class UserControl1 : Panel

{

public UserControl1()

{

InitializeComponent();

}

}

Unfortunately, the designer view doesn't provide the additional functionality. It rather stays as it was before I added the Designer attribute.

Anything else I should in order to make it happen

Thanks,

Ury





Re: .NET Base Class Library Custom panel vs. UserControl

nobugz

That's the way things are. If you want to design a custom control that looks like a panel with controls already embedded you should derive from UserControl.





Re: .NET Base Class Library Custom panel vs. UserControl

ury

Just to make sure I understand:

In VS, there's no way to visually design a custom control unless it is directly inherited from (only) UserControl. Is this correct





Re: .NET Base Class Library Custom panel vs. UserControl

nobugz

That's correct. If you find another way of doing it, please let us know.