ToolboxComponentsCreatedEventHandler Delegado

Definición

Representa el método que controla el 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)

Parámetros

sender
Object

Origen del evento.The source of the event.

e
ToolboxComponentsCreatedEventArgs

ToolboxComponentsCreatedEventArgs que proporciona datos para el evento.A ToolboxComponentsCreatedEventArgs that provides data for the event.

Ejemplos

El siguiente código de ejemplo proporciona un método que asocia un controlador de eventos para el ComponentsCreated evento de ToolboxItem .The following example code provides a method that attaches an event handler for the ComponentsCreated event of a ToolboxItem. También proporciona un ToolboxComponentsCreatedEventHandler método de control de eventos que escribe el nombre del tipo de los componentes que se crearon en Console cuando un evento genera el controlador de eventos ComponentsCreated .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

Comentarios

Cuando se crea un delegado ToolboxComponentsCreatedEventHandler, se identifica el método que controlará el evento.When you create a ToolboxComponentsCreatedEventHandler delegate, you identify the method that will handle the event. Para asociar el evento al controlador, se debe agregar una instancia del delegado al evento.To associate the event with your event handler, add an instance of the delegate to the event. Siempre que se produce el evento, se llama a su controlador, a menos que se quite el delegado.The event handler is called whenever the event occurs, unless you remove the delegate. Para obtener más información sobre los delegados de controladores de eventos, vea controlar y provocar eventos.For more information about event-handler delegates, see Handling and Raising Events.

Métodos de extensión

GetMethodInfo(Delegate)

Obtiene un objeto que representa el método representado por el delegado especificado.Gets an object that represents the method represented by the specified delegate.

Se aplica a

Consulte también