DesignerEventHandler 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 DesignerCreated peristiwa dan DesignerDisposed yang dimunculkan saat dokumen dibuat atau dibuang.
public delegate void DesignerEventHandler(System::Object ^ sender, DesignerEventArgs ^ e);
public delegate void DesignerEventHandler(object sender, DesignerEventArgs e);
public delegate void DesignerEventHandler(object? sender, DesignerEventArgs e);
type DesignerEventHandler = delegate of obj * DesignerEventArgs -> unit
Public Delegate Sub DesignerEventHandler(sender As Object, e As DesignerEventArgs)
Parameter
- sender
- Object
Sumber dari peristiwa tersebut.
DesignerEventArgs yang berisi data peristiwa.
Contoh
Contoh berikut menunjukkan mendaftarkan DesignerEventHandler dan menangani DesignerCreated peristiwa dan DesignerDisposed .
public:
void LinkDesignerEvent( IDesignerEventService^ eventService )
{
// Registers an event handler for the DesignerCreated and DesignerDisposed events.
eventService->DesignerCreated += gcnew DesignerEventHandler(
this, &DesignerEventHandlerExample::OnDesignerEvent );
eventService->DesignerDisposed += gcnew DesignerEventHandler(
this, &DesignerEventHandlerExample::OnDesignerEvent );
}
private:
void OnDesignerEvent( Object^ sender, DesignerEventArgs^ e )
{
// Displays designer event information on the console.
Console::WriteLine( "Name of the root component of the created or disposed designer: " +
e->Designer->RootComponentClassName );
}
public void LinkDesignerEvent(IDesignerEventService eventService)
{
// Registers an event handler for the DesignerCreated and DesignerDisposed events.
eventService.DesignerCreated += new DesignerEventHandler(this.OnDesignerEvent);
eventService.DesignerDisposed += new DesignerEventHandler(this.OnDesignerEvent);
}
private void OnDesignerEvent(object sender, DesignerEventArgs e)
{
// Displays designer event information on the console.
Console.WriteLine("Name of the root component of the created or disposed designer: "+e.Designer.RootComponentClassName);
}
Public Sub LinkDesignerEvent(ByVal eventService As IDesignerEventService)
' Registers an event handler for the DesignerCreated and DesignerDisposed events.
AddHandler eventService.DesignerCreated, AddressOf Me.OnDesignerEvent
AddHandler eventService.DesignerDisposed, AddressOf Me.OnDesignerEvent
End Sub
Private Sub OnDesignerEvent(ByVal sender As Object, ByVal e As DesignerEventArgs)
' Displays designer event information on the console.
Console.WriteLine(("Name of the root component of the created or disposed designer: " + e.Designer.RootComponentClassName))
End Sub
Keterangan
Saat membuat DesignerEventHandler 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. |