次の方法で共有


ComponentDesigner クラス

コンポーネントのデザイン モードの動作を拡張するための基本デザイナ クラス。

この型のすべてのメンバの一覧については、ComponentDesigner メンバ を参照してください。

System.Object
   System.ComponentModel.Design.ComponentDesigner
      System.Web.UI.Design.HtmlControlDesigner
      System.Windows.Forms.Design.ComponentDocumentDesigner
      System.Windows.Forms.Design.ControlDesigner

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

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

ComponentDesigner は、デザイン モードの関連付けられているコンポーネントの動作を拡張できる簡単なデザイナを提供します。

ComponentDesigner は、空の IDesignerFilter インターフェイス実装を提供します。このクラスのメソッドは、デザイン時に関連付けられているコンポーネントの属性、プロパティ、およびイベントを調整するようにオーバーライドできます。

DesignerAttribute を使用してデザイナに型を関連付けることができます。デザイン時の動作のカスタマイズの概要については、「 デザイン時サポートの拡張 」を参照してください。

使用例

[Visual Basic, C#, C++] ComponentDesigner 実装の例とデザイナに関連付けられているコンポーネントの例を次に示します。このデザイナは、基本クラスの Initialize メソッドを呼び出す Initialize メソッドのオーバーライド、コンポーネントがダブルクリックされたときに MessageBox を表示する DoDefaultAction メソッドのオーバーライド、およびコンポーネントのショートカット メニューへのカスタム DesignerVerb メニュー コマンドを提供する Verbs プロパティ アクセサのオーバーライドを実装します。

 
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] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.ComponentModel.Design

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System.Design (System.Design.dll 内)

参照

ComponentDesigner メンバ | System.ComponentModel.Design 名前空間 | IDesigner | IDesignerFilter | デザイン時サポートの拡張 | DesignerAttribute