Compartir a través de


ComponentChangingEventHandler Delegado

Definición

Representa el método que procesará un evento ComponentChanging.

public delegate void ComponentChangingEventHandler(System::Object ^ sender, ComponentChangingEventArgs ^ e);
public delegate void ComponentChangingEventHandler(object sender, ComponentChangingEventArgs e);
public delegate void ComponentChangingEventHandler(object? sender, ComponentChangingEventArgs e);
[System.Runtime.InteropServices.ComVisible(true)]
public delegate void ComponentChangingEventHandler(object sender, ComponentChangingEventArgs e);
type ComponentChangingEventHandler = delegate of obj * ComponentChangingEventArgs -> unit
[<System.Runtime.InteropServices.ComVisible(true)>]
type ComponentChangingEventHandler = delegate of obj * ComponentChangingEventArgs -> unit
Public Delegate Sub ComponentChangingEventHandler(sender As Object, e As ComponentChangingEventArgs)

Parámetros

sender
Object

Origen del evento.

e
ComponentChangingEventArgs

Evento ComponentChangingEventArgs que contiene los datos de eventos.

Atributos

Ejemplos

En este ejemplo se muestra cómo registrar y ComponentChangingEventHandler controlar el ComponentChanging evento.

public:
   void LinkComponentChangingEvent( IComponentChangeService^ changeService )
   {
      // Registers an event handler for the ComponentChanging event.
      changeService->ComponentChanging += gcnew ComponentChangingEventHandler(
         this, &ComponentChangingEventHandlerExample::OnComponentChanging );
   }

private:
   void OnComponentChanging( Object^ sender, ComponentChangingEventArgs^ e )
   {
      // Displays changing component information on the console.
      Console::WriteLine( "Type of the component that is about to change: " +
         e->Component->GetType()->FullName );
      Console::WriteLine( "Name of the member of the component that is about to change: " +
         e->Member->Name );
   }
public void LinkComponentChangingEvent(IComponentChangeService changeService)
{
    // Registers an event handler for the ComponentChanging event.
    changeService.ComponentChanging += new ComponentChangingEventHandler(this.OnComponentChanging);            
}

private void OnComponentChanging(object sender, ComponentChangingEventArgs e)
{
    // Displays changing component information on the console.
    Console.WriteLine("Type of the component that is about to change: "+e.Component.GetType().FullName);      
    Console.WriteLine("Name of the member of the component that is about to change: "+e.Member.Name);                        
}
Public Sub LinkComponentChangingEvent(ByVal changeService As IComponentChangeService)
    ' Registers an event handler for the ComponentChanging event.
    AddHandler changeService.ComponentChanging, AddressOf Me.OnComponentChanging
End Sub

Private Sub OnComponentChanging(ByVal sender As Object, ByVal e As ComponentChangingEventArgs)
    ' Displays changing component information on the console.
    Console.WriteLine(("Type of the component that is about to change: " + e.Component.GetType().FullName))
    Console.WriteLine(("Name of the member of the component that is about to change: " + e.Member.Name))
End Sub

Comentarios

Cuando se crea un delegado ComponentChangingEventHandler, 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