The base classes for designers implement the IDesigner interface described below and the IDesignerFilter interface described in Enabling Property Filtering.
A designer object must implement the System.ComponentModel.Design.IDesigner interface:
[C#] public interface IDesigner { void Dispose(); //other methods .... IComponent Component { get {…} set {…} //other properties .... } }
The Dispose method is used when this designer object should be destroyed. It is called when a component is removed from the design container.
The Component
property provides access to the component to which the designer is attached. This property is set once when the designer is first created. The component has a site associated with it, and the designer can use this site to obtain services from the designer’s host.
System.ComponentModel.Design.ComponentDesigner is the base class for all component designers. It implements the IDesigner and IDesignerFilter interfaces. Other designers are derived from this base class.
A designer object is associated with a component through a class attribute named DesignerAttribute. This attribute takes the fully qualified name of the designer class in its constructor. Typical code for associating a designer with a class is as follows:
[C#] [DesignerAttribute(typeof (System.WinForms.Design.ControlDesigner))] public class Control : Component { }
Designer namespaces have the following convention. They follow the same class hierarchy as the components they design, except that the namespace Design is inserted into the hierarchy. For example, the designer for the class System.WinForms.Control is System.WinForms .Design.ControlDesigner. To add design-time support to a component from which you derive, you can inherit from that component’s designer.
The base class for Win Forms controls designers is System. WinForms. Design.ControlDesigner. This class derives from ComponentDesigner. It allows a custom user interface to be provided at design time for any Win Forms control. While this provides base functionality designers for RichControls shoul derive from System. WinForms. Design.RichControlDesigner.
The base class for Win Forms controls designers is System.Web.UI.Design.HtmlControlDesigner. This class derives from ComponentDesigner and implements IWebFormsControlDesigner. HtmlControlDesigner allows for custom design-time HTML rendering, and template editing support.
Note Win Forms has an integrated design-time and runtime, while Web Forms has a strong separation between design-time and runtime.
Enabling Property Filtering | Creating Designer Verbs | Win Forms Designer Sample