ComponentDesigner Class
Base designer class for extending the design mode behavior of a component.
For a list of all members of this type, see ComponentDesigner Members.
System.Object
System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Windows.Forms.Design.ComponentDocumentDesigner
System.Windows.Forms.Design.ControlDesigner
[Visual Basic] Public Class ComponentDesigner Implements IDesigner, IDisposable, IDesignerFilter [C#] public class ComponentDesigner : IDesigner, IDisposable, IDesignerFilter [C++] public __gc class ComponentDesigner : public IDesigner, IDisposable, IDesignerFilter [JScript] public class ComponentDesigner implements IDesigner, IDisposable, IDesignerFilter
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
ComponentDesigner provides a simple designer that can extend the behavior of an associated component in design mode.
ComponentDesigner provides an empty IDesignerFilter interface implementation, whose methods can be overridden to adjust the attributes, properties and events of the associated component at design time.
You can associate a designer with a type using a DesignerAttribute. For an overview of customizing design time behavior, see Enhancing Design-Time Support.
Example
[Visual Basic, C#, C++] The following example provides an example ComponentDesigner implementation and an example component associated with the designer. The designer implements an override of the Initialize method that calls the base Initialize method, an override of the DoDefaultAction method that displays a MessageBox when the component is double-clicked, and an override of the Verbs property accessor that supplies a custom DesignerVerb menu command to the shortcut menu for the component.
[Visual Basic] Imports System Imports System.Collections Imports System.ComponentModel Imports System.ComponentModel.Design Imports System.Drawing Imports System.Windows.Forms Namespace ExampleComponent ' Provides an example component designer. Public Class ExampleComponentDesigner Inherits System.ComponentModel.Design.ComponentDesigner Public Sub New() End Sub 'New ' This method provides an opportunity to perform processing when a designer is initialized. ' The component parameter is the component that the designer is associated with. Public Overrides Sub Initialize(ByVal component As System.ComponentModel.IComponent) ' Always call the base Initialize method in an override of this method. MyBase.Initialize(component) End Sub 'Initialize ' This method is invoked when the associated component is double-clicked. Public Overrides Sub DoDefaultAction() MessageBox.Show("The event handler for the default action was invoked.") End Sub 'DoDefaultAction ' This method provides designer verbs. Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection Get Return New DesignerVerbCollection(New DesignerVerb() {New DesignerVerb("Example Designer Verb Command", New EventHandler(AddressOf Me.onVerb))}) End Get End Property ' Event handling method for the example designer verb Private Sub onVerb(ByVal sender As Object, ByVal e As EventArgs) MessageBox.Show("The event handler for the Example Designer Verb Command was invoked.") End Sub 'onVerb End Class 'ExampleComponentDesigner ' Provides an example component associated with the example component designer. <DesignerAttribute(GetType(ExampleComponentDesigner), GetType(IDesigner))> _ Public Class ExampleComponent Inherits System.ComponentModel.Component Public Sub New() End Sub 'New End Class 'ExampleComponent End Namespace 'ExampleComponent [C#] using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing; using System.Windows.Forms; namespace ExampleComponent { // Provides an example component designer. public class ExampleComponentDesigner : System.ComponentModel.Design.ComponentDesigner { public ExampleComponentDesigner() { } // This method provides an opportunity to perform processing when a designer is initialized. // The component parameter is the component that the designer is associated with. public override void Initialize(System.ComponentModel.IComponent component) { // Always call the base Initialize method in an override of this method. base.Initialize(component); } // This method is invoked when the associated component is double-clicked. public override void DoDefaultAction() { MessageBox.Show("The event handler for the default action was invoked."); } // This method provides designer verbs. public override System.ComponentModel.Design.DesignerVerbCollection Verbs { get { return new DesignerVerbCollection( new DesignerVerb[] { new DesignerVerb("Example Designer Verb Command", new EventHandler(this.onVerb)) } ); } } // Event handling method for the example designer verb private void onVerb(object sender, EventArgs e) { MessageBox.Show("The event handler for the Example Designer Verb Command was invoked."); } } // Provides an example component associated with the example component designer. [DesignerAttribute(typeof(ExampleComponentDesigner), typeof(IDesigner))] public class ExampleComponent : System.ComponentModel.Component { public ExampleComponent() { } } } [C++] #using <mscorlib.dll> #using <System.dll> #using <System.Design.dll> #using <System.Drawing.dll> #using <System.Windows.Forms.dll> using namespace System; using namespace System::Collections; using namespace System::ComponentModel; using namespace System::ComponentModel::Design; using namespace System::Drawing; using namespace System::Windows::Forms; // Provides an example component designer. __gc class ExampleComponentDesigner : public ComponentDesigner { public: ExampleComponentDesigner() {} // This method provides an opportunity to perform processing when a designer is initialized. // The component parameter is the component that the designer is associated with. void Initialize(IComponent* component) { // Always call the base Initialize method in an of this method. ComponentDesigner::Initialize(component); } // This method is invoked when the associated component is double-clicked. void DoDefaultAction() { MessageBox::Show(S"The event handler for the default action was invoked."); } // This method provides designer verbs. __property DesignerVerbCollection* get_Verbs() { DesignerVerb* newDesignerVerbs[] = { new DesignerVerb(S"Example Designer Verb Command", new EventHandler(this, &ExampleComponentDesigner::onVerb))}; return new DesignerVerbCollection(newDesignerVerbs); } private: // Event handling method for the example designer verb void onVerb(Object* sender, EventArgs* e) { MessageBox::Show(S"The event handler for the Example Designer Verb Command was invoked."); } }; // Provides an example component associated with the example component designer. [DesignerAttribute(__typeof(ExampleComponentDesigner), __typeof(IDesigner))] __gc class ExampleComponent : public Component { public: ExampleComponent() {} };
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.ComponentModel.Design
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System.Design (in System.Design.dll)
See Also
ComponentDesigner Members | System.ComponentModel.Design Namespace | IDesigner | IDesignerFilter | Enhancing Design-Time Support | DesignerAttribute