Reputation: 1421
I know that getting the Form Designer to work is a ticklish business. Generics, x64, subtle problems with the project's XML... But perhaps someone can offer advice about my current problem, which is that a component I created that inherits from TabPage
, when I try to view it in the designer shows up as a list of its controls, like this:
Thanks in advance.
Upvotes: 0
Views: 1356
Reputation: 125322
You cannot make a TabPage
as root of the designer, while you can do the same for a Panel
or other container controls. The limitation is because, TabPage
can only be hosted in TabControl
, not even in the overlay control of the designer:
TabPage cannot be added to a 'System.Windows.Forms.Design.DesignerFrame+OverlayControl'. TabPages can only be added to TabControls.
A control can be shown as root of the designer when the base class of the control has designer of type of DocumentDesigner
. Form
and UserControl
are such controls which means when you create a new Form1:Form
or new UserControl1:UserControl
, since the base class derived from a designable control, then the class can be edited in the designer as root.
I believe you can handle your requirement by using UserControl
, but for learning purpose (or as a workaround) if you want to make a control deriving from Panel
designable, you can copy the following code in a code file:
public class MyControl: MyDesignableControl
{
}
[Designer(typeof(DocumentDesigner), typeof(IRootDesigner))]
public class MyDesignableControl : Panel
{
}
Then save it and then double click on it and you can see you can design it like a root control.
Then after you done with the design, change the Panel
to TabPage
.
This designer is a root designer, meaning that it provides the root-level design mode view for the associated document when it is viewed in design mode.
You can associate a designer with a type using a
DesignerAttribute
. For an overview of customizing design time behavior, see Extending Design-Time Support.
Upvotes: 2