ComponentChangedEventHandler Delegasikan
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mewakili metode yang akan menangani ComponentChanged peristiwa.
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)
Parameter
- sender
- Object
Sumber dari peristiwa tersebut.
ComponentChangedEventArgs yang berisi data peristiwa.
- Atribut
Contoh
Contoh ini menunjukkan mendaftarkan ComponentChangedEventHandler dan menangani ComponentChanged peristiwa.
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
Keterangan
Saat membuat ComponentChangedEventHandler 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.
Peristiwa ComponentChanged tidak akan terjadi selama pemuatan atau pembongkaran formulir karena perubahan diharapkan selama operasi ini.
Metode Ekstensi
GetMethodInfo(Delegate) |
Mendapatkan objek yang mewakili metode yang diwakili oleh delegasi yang ditentukan. |