ComponentChangedEventHandler Delegato

Definizione

Rappresenta il metodo che gestirà un evento ComponentChanged.

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

Parametri

sender
Object

Origine dell'evento.

e
ComponentChangedEventArgs

Oggetto ComponentChangedEventArgs che contiene i dati dell'evento.

Attributi

Esempio

In questo esempio viene illustrata la registrazione di un ComponentChangedEventHandler oggetto e la gestione dell'evento ComponentChanged .

public:
   void LinkComponentChangedEvent( IComponentChangeService^ changeService )
   {
      // Registers an event handler for the ComponentChanged event.
      changeService->ComponentChanged += gcnew ComponentChangedEventHandler(
         this, &ComponentChangedEventHandlerExample::OnComponentChanged );
   }

private:
   void OnComponentChanged( Object^ sender, ComponentChangedEventArgs^ e )
   {
      // Displays changed component information on the console.
      Console::WriteLine( "Type of the component that has changed: " +
         e->Component->GetType()->FullName );
      Console::WriteLine( "Name of the member of the component that has changed: " +
         e->Member->Name );
      Console::WriteLine( "Old value of the member: " + e->OldValue );
      Console::WriteLine( "New value of the member: " + e->NewValue );
   }
public void LinkComponentChangedEvent(IComponentChangeService changeService)
{
    // Registers an event handler for the ComponentChanged event.
    changeService.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);            
}

private void OnComponentChanged(object sender, ComponentChangedEventArgs e)
{
    // Displays changed component information on the console.
    Console.WriteLine("Type of the component that has changed: "+e.Component.GetType().FullName);      
    Console.WriteLine("Name of the member of the component that has changed: "+e.Member.Name);            
    Console.WriteLine("Old value of the member: "+e.OldValue.ToString());
    Console.WriteLine("New value of the member: "+e.NewValue.ToString());
}
Public Sub LinkComponentChangedEvent(ByVal changeService As IComponentChangeService)
    ' Registers an event handler for the ComponentChanged event.
    AddHandler changeService.ComponentChanged, AddressOf Me.OnComponentChanged
End Sub

Private Sub OnComponentChanged(ByVal sender As Object, ByVal e As ComponentChangedEventArgs)
    ' Displays changed component information on the console.            
    Console.WriteLine(("Type of the component that has changed: " + e.Component.GetType().FullName))
    Console.WriteLine(("Name of the member of the component that has changed: " + e.Member.Name))
    Console.WriteLine(("Old value of the member: " + e.OldValue.ToString()))
    Console.WriteLine(("New value of the member: " + e.NewValue.ToString()))
End Sub

Commenti

Quando si crea un delegato ComponentChangedEventHandler, si identifica il metodo che gestirà l'evento. Per associare l'evento al gestore eventi in uso, aggiungere all'evento un'istanza del delegato. Il gestore eventi viene chiamato ogni volta che si verifica l'evento, a meno che non venga rimosso il delegato. Per altre informazioni sui delegati del gestore eventi, vedere Gestione e generazione di eventi.

Un ComponentChanged evento non si verificherà durante il caricamento o lo scaricamento di un modulo perché durante queste operazioni sono previste modifiche.

Metodi di estensione

GetMethodInfo(Delegate)

Ottiene un oggetto che rappresenta il metodo rappresentato dal delegato specificato.

Si applica a

Vedi anche