Udostępnij za pośrednictwem


ComponentRenameEventHandler Delegat

Definicja

Reprezentuje metodę, która będzie obsługiwać ComponentRename zdarzenie.

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)

Parametry

sender
Object

Źródło zdarzenia.

e
ComponentRenameEventArgs

Element ComponentRenameEventArgs zawierający dane zdarzenia.

Atrybuty

Przykłady

W poniższym przykładzie pokazano rejestrowanie ComponentRenameEventHandler zdarzenia i obsługę go 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

Uwagi

Podczas tworzenia delegata ComponentRenameEventHandler należy zidentyfikować metodę, która będzie obsługiwać zdarzenie. Aby skojarzyć zdarzenie z programem obsługi zdarzeń, dodaj wystąpienie delegata do zdarzenia. Program obsługi zdarzeń jest wywoływany przy każdym wystąpieniu zdarzenia, o ile nie usunięto delegata. Aby uzyskać więcej informacji na temat delegatów programu obsługi zdarzeń, zobacz Obsługa i podnoszenie zdarzeń.

Metody rozszerzania

GetMethodInfo(Delegate)

Pobiera obiekt reprezentujący metodę reprezentowaną przez określonego delegata.

Dotyczy

Zobacz też