ComponentRenameEventHandler Delegato

Definizione

Rappresenta il metodo che gestirà un ComponentRename evento.

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

Parametri

sender
Object

La fonte dell'evento.

e
ComponentRenameEventArgs

Oggetto ComponentRenameEventArgs contenente i dati dell'evento.

Attributi

Esempio

Nell'esempio seguente viene illustrata la registrazione di un ComponentRenameEventHandler oggetto e la gestione dell'evento ComponentRename .

public:
   void LinkComponentRenameEvent( IComponentChangeService^ changeService )
   {
      // Registers an event handler for the ComponentRename event.
      changeService->ComponentRename += gcnew ComponentRenameEventHandler(
         this, &ComponentRenameEventHandlerExample::OnComponentRename );
   }

private:
   void OnComponentRename( Object^ /*sender*/, ComponentRenameEventArgs^ e )
   {
      // Displayss component renamed information on the console.
      Console::WriteLine( "Type of the component that has been renamed: " +
         e->Component->GetType()->FullName );
      Console::WriteLine( "New name of the component that has been renamed: " +
         e->NewName );
      Console::WriteLine( "Old name of the component that has been renamed: " +
         e->OldName );
   }
public void LinkComponentRenameEvent(IComponentChangeService changeService)
{
    // Registers an event handler for the ComponentRename event.
    changeService.ComponentRename += new ComponentRenameEventHandler(this.OnComponentRename);            
}

private void OnComponentRename(object sender, ComponentRenameEventArgs e)
{
    // Displayss component renamed information on the console.           
    Console.WriteLine("Type of the component that has been renamed: "+e.Component.GetType().FullName);                  
    Console.WriteLine("New name of the component that has been renamed: "+e.NewName);
    Console.WriteLine("Old name of the component that has been renamed: "+e.OldName);
}
Public Sub LinkComponentRenameEvent(ByVal changeService As IComponentChangeService)
    ' Registers an event handler for the ComponentRename event.
    AddHandler changeService.ComponentRename, AddressOf Me.OnComponentRename
End Sub

Private Sub OnComponentRename(ByVal sender As Object, ByVal e As ComponentRenameEventArgs)
    ' Displays component renamed information on the console.           
    Console.WriteLine(("Type of the component that has been renamed: " + e.Component.GetType().FullName))
    Console.WriteLine(("New name of the component that has been renamed: " + e.NewName))
    Console.WriteLine(("Old name of the component that has been renamed: " + e.OldName))
End Sub

Commenti

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

Metodi di estensione

Nome Descrizione
GetMethodInfo(Delegate)

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

Si applica a

Vedi anche