ToolboxComponentsCreatingEventHandler 委托

定义

表示 ComponentsCreating 事件的处理方法。

public delegate void ToolboxComponentsCreatingEventHandler(System::Object ^ sender, ToolboxComponentsCreatingEventArgs ^ e);
public delegate void ToolboxComponentsCreatingEventHandler(object sender, ToolboxComponentsCreatingEventArgs e);
type ToolboxComponentsCreatingEventHandler = delegate of obj * ToolboxComponentsCreatingEventArgs -> unit
Public Delegate Sub ToolboxComponentsCreatingEventHandler(sender As Object, e As ToolboxComponentsCreatingEventArgs)

参数

sender
Object

事件源。

示例

以下示例代码提供了一个方法,该方法为 ComponentsCreating 的事件ToolboxItem附加事件处理程序,以及一个ToolboxComponentsCreatingEventHandler事件处理程序方法,该方法将组件类型的名称写入事件引发ComponentsCreating事件处理程序时要接收新组件或 组件Console

public:
   [PermissionSetAttribute(SecurityAction::Demand, Name="FullTrust")]
   void LinkToolboxComponentsCreatingEvent( ToolboxItem^ item )
   {
      item->ComponentsCreating +=
         gcnew ToolboxComponentsCreatingEventHandler( this, &Form1::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 );
   }
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);
}
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

注解

创建 ToolboxComponentsCreatingEventHandler 委托时,需要标识将处理该事件的方法。 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。 除非移除了该委托,否则每当发生该事件时就会调用事件处理程序。 有关事件处理程序委托的详细信息,请参阅 处理和引发事件

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。

适用于

另请参阅