Article ID: 813450 - Last Review: July 16, 2008 - Revision: 3.1 How to make a UserControl object acts as a control container design-time by using Visual C#On This PageSUMMARY This step-by-step article describes how to make a UserControl object act as a control container at design-time after you put
the UserControl on a Windows Form. There may be situations where you want to drag
a control to your UserControl. To do this, the UserControl must act as a control container. OverviewBy default, a UserControl object can act as a control container only when you create the control. To make a UserControl host a constituent control after you put the UserControl on a Windows Form, you must change the default designer of the UserControl. To implement design-time services for a component, use the DesignerAttribute class of the System.ComponentModel namespace. The DesignerAttribute comes before the class declaration. Initialize the DesignerAttribute by passing the designerTypeName and the designerBaseType parameters. designerTypeName is the fully qualified name of the designer type that provides design-time services. Pass the combination of the System.Windows.Forms.Design.ParentControlDesigner and the System.Design for the designerTypeName parameter. The ParentControlDesigner class extends design-time behavior for a UserControl. designerBaseType is the name of the base class for the designer. The class that is used for the design-time services must implement the IDesigner interface. Create the UserControl as a Design-Time Control Container
Test the UserControl
REFERENCES For more information, see the following Microsoft Web
sites:
ParentControlDesigner Class http://msdn.microsoft.com/en-us/library/system.windows.forms.design.parentcontroldesigner(VS.71).aspx (http://msdn.microsoft.com/en-us/library/system.windows.forms.design.parentcontroldesigner(VS.71).aspx) DesignerAttribute Class http://msdn.microsoft.com/en-us/library/system.componentmodel.designerattribute(vs.71).aspx (http://msdn.microsoft.com/en-us/library/system.windows.forms.design.parentcontroldesigner(VS.71).aspx) | Article Translations
|

Back to the top
