Bagikan melalui


ComponentChangingEventHandler Delegasikan

Definisi

Mewakili metode yang akan menangani ComponentChanging peristiwa.

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)

Parameter

sender
Object

Sumber dari peristiwa tersebut.

e
ComponentChangingEventArgs

Peristiwa ComponentChangingEventArgs yang berisi data peristiwa.

Atribut

Contoh

Contoh ini menunjukkan mendaftarkan ComponentChangingEventHandler dan menangani ComponentChanging peristiwa.

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

Keterangan

Saat membuat ComponentChangingEventHandler delegasi, Anda mengidentifikasi metode yang akan menangani peristiwa. Untuk mengaitkan peristiwa dengan penanganan aktivitas Anda, tambahkan instans delegasi ke peristiwa. Penanganan aktivitas dipanggil setiap kali peristiwa terjadi, kecuali Jika Anda menghapus delegasi. Untuk informasi selengkapnya tentang delegasi penanganan aktivitas, lihat Menangani dan Meningkatkan Peristiwa.

Metode Ekstensi

GetMethodInfo(Delegate)

Mendapatkan objek yang mewakili metode yang diwakili oleh delegasi yang ditentukan.

Berlaku untuk

Lihat juga