ActiveDesignerEventHandler 代理人
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示處理 ActiveDesignerChanged 事件的方法。
public delegate void ActiveDesignerEventHandler(System::Object ^ sender, ActiveDesignerEventArgs ^ e);
public delegate void ActiveDesignerEventHandler(object sender, ActiveDesignerEventArgs e);
public delegate void ActiveDesignerEventHandler(object? sender, ActiveDesignerEventArgs e);
type ActiveDesignerEventHandler = delegate of obj * ActiveDesignerEventArgs -> unit
Public Delegate Sub ActiveDesignerEventHandler(sender As Object, e As ActiveDesignerEventArgs)
參數
- sender
- Object
事件的來源。
包含事件資料的 ActiveDesignerEventArgs。
範例
下列範例示範註冊 ActiveDesignerEventHandler 和處理 ActiveDesignerChanged 事件。
public:
void LinkActiveDesignerEvent( IDesignerEventService^ eventService )
{
// Registers an event handler for the ActiveDesignerChanged event.
eventService->ActiveDesignerChanged += gcnew ActiveDesignerEventHandler( this, &MiscCompModSamples::ActiveDesignerEventHandlerExample::OnActiveDesignerEvent );
}
private:
void OnActiveDesignerEvent( Object^ /*sender*/, ActiveDesignerEventArgs^ e )
{
// Displays changed designer information on the console.
if ( e->NewDesigner->RootComponent->Site != nullptr )
{
Console::WriteLine( "Name of the component of the new active designer: {0}", e->NewDesigner->RootComponent->Site->Name );
}
Console::WriteLine( "Type of the component of the new active designer: {0}", e->NewDesigner->RootComponentClassName );
if ( e->OldDesigner->RootComponent->Site != nullptr )
{
Console::WriteLine( "Name of the component of the previously active designer: {0}", e->OldDesigner->RootComponent->Site->Name );
}
Console::WriteLine( "Type of the component of the previously active designer: {0}", e->OldDesigner->RootComponentClassName );
}
public void LinkActiveDesignerEvent(IDesignerEventService eventService)
{
// Registers an event handler for the ActiveDesignerChanged event.
eventService.ActiveDesignerChanged += new ActiveDesignerEventHandler(this.OnActiveDesignerEvent);
}
private void OnActiveDesignerEvent(object sender, ActiveDesignerEventArgs e)
{
// Displays changed designer information on the console.
if( e.NewDesigner.RootComponent.Site != null )
Console.WriteLine("Name of the component of the new active designer: "+e.NewDesigner.RootComponent.Site.Name);
Console.WriteLine("Type of the component of the new active designer: "+e.NewDesigner.RootComponentClassName);
if( e.OldDesigner.RootComponent.Site != null )
Console.WriteLine("Name of the component of the previously active designer: "+e.OldDesigner.RootComponent.Site.Name);
Console.WriteLine("Type of the component of the previously active designer: "+e.OldDesigner.RootComponentClassName);
}
Public Sub LinkActiveDesignerEvent(ByVal eventService As IDesignerEventService)
' Registers an event handler for the ActiveDesignerChanged event.
AddHandler eventService.ActiveDesignerChanged, AddressOf Me.OnActiveDesignerEvent
End Sub
Private Sub OnActiveDesignerEvent(ByVal sender As Object, ByVal e As ActiveDesignerEventArgs)
' Displays changed designer information on the console.
If (e.NewDesigner.RootComponent.Site IsNot Nothing) Then
Console.WriteLine(("Name of the component of the new active designer: " + e.NewDesigner.RootComponent.Site.Name))
End If
Console.WriteLine(("Type of the component of the new active designer: " + e.NewDesigner.RootComponentClassName))
If (e.OldDesigner.RootComponent.Site IsNot Nothing) Then
Console.WriteLine(("Name of the component of the previously active designer: " + e.OldDesigner.RootComponent.Site.Name))
End If
Console.WriteLine(("Type of the component of the previously active designer: " + e.OldDesigner.RootComponentClassName))
End Sub
備註
當目前使用中檔已修改時,就會 ActiveDesignerChanged 引發 事件。
當您建立 ActiveDesignerEventHandler 委派 (Delegate) 時,就可以識別即將處理此事件的方法。 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (Instance) 加入至事件。 除非您移除委派,否則每當事件發生時就會呼叫事件處理常式。 如需事件處理程式委派的詳細資訊,請參閱 處理和引發事件。
擴充方法
GetMethodInfo(Delegate) |
取得表示特定委派所代表之方法的物件。 |