ComponentRenameEventHandler Délégué

Définition

Représente la méthode qui gérera un événement ComponentRename.

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

Paramètres

sender
Object

Source de l'événement.

e
ComponentRenameEventArgs

ComponentRenameEventArgs qui contient les données d’événement.

Attributs

Exemples

L’exemple suivant illustre l’inscription d’un ComponentRenameEventHandler et la gestion de l’événement 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

Remarques

Lorsque vous créez un délégué ComponentRenameEventHandler, vous identifiez la méthode qui gérera l'événement. Pour associer l'événement au gestionnaire d'événements, ajoutez une instance du délégué à l'événement. Le gestionnaire d'événements est appelé chaque fois qu'un événement se produit, sauf si vous supprimez le délégué. Pour plus d’informations sur les délégués du gestionnaire d’événements, consultez Gestion et levée d’événements.

Méthodes d’extension

GetMethodInfo(Delegate)

Obtient un objet qui représente la méthode représentée par le délégué spécifié.

S’applique à

Voir aussi