ActiveDesignerEventHandler 대리자

정의

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

이벤트 소스입니다.

e
ActiveDesignerEventArgs

이벤트 데이터가 포함된 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 대리자를 만드는 경우 이벤트를 처리할 메서드를 결정합니다. 이벤트를 이벤트 처리기와 연결하려면 대리자의 인스턴스를 해당 이벤트에 추가합니다. 대리자를 제거하지 않는 경우 이벤트가 발생할 때마다 이벤트 처리기가 호출됩니다. 이벤트 처리기 대리자에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.

확장 메서드

GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상

추가 정보