ToolboxComponentsCreatedEventHandler Delegat

Definition

Stellt die Methode dar, die das ComponentsCreated-Ereignis behandelt.Represents the method that handles the ComponentsCreated event.

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

Parameter

sender
Object

Die Quelle des Ereignisses.The source of the event.

e
ToolboxComponentsCreatedEventArgs

Ein ToolboxComponentsCreatedEventArgs, das Daten für das Ereignis bereitstellt.A ToolboxComponentsCreatedEventArgs that provides data for the event.

Vererbung
ToolboxComponentsCreatedEventHandler

Beispiele

Der folgende Beispielcode stellt eine Methode bereit, die einen Ereignishandler für ComponentsCreated das-Ereignis ToolboxItemeines anfügt.The following example code provides a method that attaches an event handler for the ComponentsCreated event of a ToolboxItem. Außerdem wird eine ToolboxComponentsCreatedEventHandler Ereignishandlermethode bereitstellt, die den Namen des Typs der Komponenten schreibt, die Console in erstellt wurden, wenn der Ereignishandler durch ComponentsCreated ein-Ereignis ausgelöst wird.It also provides a ToolboxComponentsCreatedEventHandler event handler method that writes the name of the type of the components that were created to the Console when the event handler is raised by a ComponentsCreated event.

public:
   [PermissionSetAttribute(SecurityAction::Demand, Name="FullTrust")]
   void LinkToolboxComponentsCreatedEvent( ToolboxItem^ item )
   {
      item->ComponentsCreated +=
         gcnew ToolboxComponentsCreatedEventHandler( this, &Form1::OnComponentsCreated );
   }

private:
   void OnComponentsCreated( Object^ sender, ToolboxComponentsCreatedEventArgs^ e )
   {
      // Lists created components on the Console.
      for ( int i = 0; i < e->Components->Length; i++ )
      {
         Console::WriteLine( "Component #" + i + ": " +
            e->Components[ i ]->Site->Name );
      }
   }
public void LinkToolboxComponentsCreatedEvent(ToolboxItem item)
{
    item.ComponentsCreated += new ToolboxComponentsCreatedEventHandler(this.OnComponentsCreated);
}

private void OnComponentsCreated(object sender, ToolboxComponentsCreatedEventArgs e)
{
    // Lists created components on the Console.
    for( int i=0; i< e.Components.Length; i++ )
        Console.WriteLine("Component #"+i.ToString()+": "+e.Components[i].Site.Name.ToString());            
}
Public Sub LinkToolboxComponentsCreatedEvent(ByVal item As ToolboxItem)
    AddHandler item.ComponentsCreated, AddressOf Me.OnComponentsCreated
End Sub

Private Sub OnComponentsCreated(ByVal sender As Object, ByVal e As ToolboxComponentsCreatedEventArgs)
    ' Lists created components on the Console.
    Dim i As Integer
    For i = 0 To e.Components.Length - 1
        Console.WriteLine(("Component #" + i.ToString() + ": " + e.Components(i).Site.Name.ToString()))
    Next i
End Sub

Hinweise

Beim Erstellen eines ToolboxComponentsCreatedEventHandler-Delegaten bestimmen Sie die Methode für die Ereignisbehandlung.When you create a ToolboxComponentsCreatedEventHandler delegate, you identify the method that will handle the event. Um dem Ereignishandler das Ereignis zuzuordnen, fügen Sie dem Ereignis eine Instanz des Delegaten hinzu.To associate the event with your event handler, add an instance of the delegate to the event. Der Ereignishandler wird bei jedem Eintreten des Ereignisses aufgerufen, sofern der Delegat nicht entfernt wird.The event handler is called whenever the event occurs, unless you remove the delegate. Weitere Informationen zu Ereignishandlerdelegaten finden Sie unter behandeln und Auswerfen von Ereignissen.For more information about event-handler delegates, see Handling and Raising Events.

Erweiterungsmethoden

GetMethodInfo(Delegate)

Ruft ein Objekt ab, das die Methode darstellt, die vom angegebenen Delegaten dargestellt wird.Gets an object that represents the method represented by the specified delegate.

Gilt für:

Siehe auch