ToolboxComponentsCreatedEventHandler ToolboxComponentsCreatedEventHandler ToolboxComponentsCreatedEventHandler ToolboxComponentsCreatedEventHandler Delegate

Definizione

Rappresenta il metodo che gestisce l'evento ComponentsCreated.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)

Parametri

sender
Object Object Object Object

Origine dell'evento.The source of the event.

Ereditarietà
ToolboxComponentsCreatedEventHandlerToolboxComponentsCreatedEventHandlerToolboxComponentsCreatedEventHandlerToolboxComponentsCreatedEventHandler

Esempi

Il codice di esempio seguente fornisce un metodo che connette un gestore eventi per l' ComponentsCreated evento di un ToolboxItemoggetto.The following example code provides a method that attaches an event handler for the ComponentsCreated event of a ToolboxItem. Fornisce inoltre un ToolboxComponentsCreatedEventHandler metodo del gestore eventi che scrive il nome del tipo di componenti creati Console in quando il gestore eventi viene generato da un ComponentsCreated evento.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

Commenti

Quando si crea un delegato ToolboxComponentsCreatedEventHandler, si identifica il metodo che gestirà l'evento.When you create a ToolboxComponentsCreatedEventHandler delegate, you identify the method that will handle the event. Per associare l'evento al gestore eventi in uso, aggiungere all'evento un'istanza del delegato.To associate the event with your event handler, add an instance of the delegate to the event. Il gestore eventi viene chiamato ogni volta che si verifica l'evento, a meno che non venga rimosso il delegato.The event handler is called whenever the event occurs, unless you remove the delegate. Per ulteriori informazioni sui delegati del gestore eventi, vedere gestione e generazione di eventi.For more information about event-handler delegates, see Handling and Raising Events.

Metodi di estensione

GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate)

Ottiene un oggetto che rappresenta il metodo rappresentato dal delegato specificato.Gets an object that represents the method represented by the specified delegate.

Si applica a

Vedi anche