DesignerEventHandler Delegado

Definición

Representa el método que controlará los eventos DesignerCreated y DesignerDisposed que se provocan al crear o eliminar un documento.

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

Parámetros

sender
Object

Origen del evento.

e
DesignerEventArgs

Objeto DesignerEventArgs que contiene los datos del evento.

Ejemplos

En el ejemplo siguiente se muestra cómo registrar y DesignerEventHandler controlar los DesignerCreated eventos y DesignerDisposed .

public:
   void LinkDesignerEvent( IDesignerEventService^ eventService )
   {
      // Registers an event handler for the DesignerCreated and DesignerDisposed events.
      eventService->DesignerCreated += gcnew DesignerEventHandler(
         this, &DesignerEventHandlerExample::OnDesignerEvent );
      eventService->DesignerDisposed += gcnew DesignerEventHandler(
         this, &DesignerEventHandlerExample::OnDesignerEvent );
   }

private:
   void OnDesignerEvent( Object^ sender, DesignerEventArgs^ e )
   {
      // Displays designer event information on the console.
      Console::WriteLine( "Name of the root component of the created or disposed designer: " +
         e->Designer->RootComponentClassName );
   }
public void LinkDesignerEvent(IDesignerEventService eventService)
{                                   
    // Registers an event handler for the DesignerCreated and DesignerDisposed events.
    eventService.DesignerCreated += new DesignerEventHandler(this.OnDesignerEvent);
    eventService.DesignerDisposed += new DesignerEventHandler(this.OnDesignerEvent);            
}

private void OnDesignerEvent(object sender, DesignerEventArgs e)
{
    // Displays designer event information on the console.
    Console.WriteLine("Name of the root component of the created or disposed designer: "+e.Designer.RootComponentClassName);
}
Public Sub LinkDesignerEvent(ByVal eventService As IDesignerEventService)
    ' Registers an event handler for the DesignerCreated and DesignerDisposed events.
    AddHandler eventService.DesignerCreated, AddressOf Me.OnDesignerEvent
    AddHandler eventService.DesignerDisposed, AddressOf Me.OnDesignerEvent
End Sub

Private Sub OnDesignerEvent(ByVal sender As Object, ByVal e As DesignerEventArgs)
    ' Displays designer event information on the console.
    Console.WriteLine(("Name of the root component of the created or disposed designer: " + e.Designer.RootComponentClassName))
End Sub

Comentarios

Cuando se crea un delegado DesignerEventHandler, se identifica el método que controlará el evento. Para asociar el evento al controlador, se debe agregar una instancia del delegado al evento. Siempre que se produce el evento, se llama a su controlador, a menos que se quite el delegado. Para obtener más información sobre los delegados del controlador de eventos, vea Control y generación de eventos.

Métodos de extensión

GetMethodInfo(Delegate)

Obtiene un objeto que representa el método representado por el delegado especificado.

Se aplica a

Consulte también