次の方法で共有


ToolboxComponentsCreatingEventHandler デリゲート

ComponentsCreating イベントを処理するメソッドを表します。

<Serializable>
Public Delegate Sub ToolboxComponentsCreatingEventHandler( _   ByVal sender As Object, _   ByVal e As ToolboxComponentsCreatingEventArgs _)
[C#]
[Serializable]
public delegate void ToolboxComponentsCreatingEventHandler(   object sender,   ToolboxComponentsCreatingEventArgs e);
[C++]
[Serializable]
public __gc __delegate void ToolboxComponentsCreatingEventHandler(   Object* sender,   ToolboxComponentsCreatingEventArgs* e);

[JScript] JScript では、.NET Framework のデリゲートを利用することができます。ただし、独自に定義することはできません。

パラメータ [Visual Basic, C#, C++]

作成するイベント ハンドラは、ToolboxComponentsCreatingEventHandler クラスのデリゲート定義と同一のパラメータを持つ必要があります。

解説

ToolboxComponentsCreatingEventHandler デリゲートを作成する場合は、イベントを処理するメソッドを識別してください。イベントをイベント ハンドラに関連付けるには、デリゲートのインスタンスをイベントに追加します。デリゲートを削除しない限り、そのイベントが発生すると常にイベント ハンドラが呼び出されます。イベント ハンドラ デリゲートの詳細については、「 イベントとデリゲート 」を参照してください。

使用例

[Visual Basic, C#, C++] 次に示すのは、 ToolboxItemComponentsCreating イベントにイベント ハンドラをアタッチするメソッドの実装例です。このコードではまた、 ToolboxComponentsCreatingEventHandler イベント ハンドラ メソッドも実装されています。このメソッドは、 ComponentsCreating イベントによってイベント ハンドラが呼び出されたときに、新しいコンポーネントの種類名を Console に書き込みます。

 
Public Sub LinkToolboxComponentsCreatingEvent(ByVal item As ToolboxItem)
    AddHandler item.ComponentsCreating, AddressOf Me.OnComponentsCreating
End Sub

Private Sub OnComponentsCreating(ByVal sender As Object, ByVal e As ToolboxComponentsCreatingEventArgs)
    ' Displays ComponentsCreating event information on the Console.
    Console.WriteLine(("Name of the class of the root component of the designer host receiving new components: " + e.DesignerHost.RootComponentClassName))
End Sub

[C#] 
public void LinkToolboxComponentsCreatingEvent(ToolboxItem item)
{
    item.ComponentsCreating += new ToolboxComponentsCreatingEventHandler(this.OnComponentsCreating);
}

private void OnComponentsCreating(object sender, ToolboxComponentsCreatingEventArgs e)
{
    // Displays ComponentsCreating event information on the Console.
    Console.WriteLine("Name of the class of the root component of " +
    "the designer host receiving new components: " +
    e.DesignerHost.RootComponentClassName);
}

[C++] 
public:
    void LinkToolboxComponentsCreatingEvent(ToolboxItem* item) {
        item->ComponentsCreating += new ToolboxComponentsCreatingEventHandler(this, &Form1::OnComponentsCreating);
    }

private:
    void OnComponentsCreating(Object* /*sender*/, ToolboxComponentsCreatingEventArgs* e) {
        // Displays ComponentsCreating event information on the Console.
        Console::WriteLine(S"Name of the class of the root component of the designer host receiving new components: {0}",
            e->DesignerHost->RootComponentClassName);
    }

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

必要条件

名前空間: System.Drawing.Design

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

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

参照

System.Drawing.Design 名前空間 | ToolboxComponentsCreatingEventArgs | ComponentsCreating