DesignerEventHandler 代理人
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示處理建立或配置文件時所引發的 DesignerCreated 和 DesignerDisposed 事件的方法。
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)
參數
- sender
- Object
事件的來源。
DesignerEventArgs,其中包含事件資料。
範例
下列範例示範如何 DesignerEventHandler 註冊 和處理 DesignerCreated 和 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
備註
建立 DesignerEventHandler 委派時,必須識別處理事件的方法。 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (Instance) 加入至事件。 除非您移除委派,否則每當事件發生時就會呼叫事件處理常式。 如需事件處理程式委派的詳細資訊,請參閱 處理和引發事件。
擴充方法
GetMethodInfo(Delegate) |
取得表示特定委派所代表之方法的物件。 |