Sdílet prostřednictvím


ActiveDesignerEventHandler Delegát

Definice

Představuje metodu, která bude zpracovávat ActiveDesignerChanged událost.

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)

Parametry

sender
Object

Zdroj události

e
ActiveDesignerEventArgs

Objekt ActiveDesignerEventArgs , který obsahuje data události.

Příklady

Následující příklad ukazuje registraci ActiveDesignerEventHandler a zpracování ActiveDesignerChanged události.

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

Poznámky

Událost ActiveDesignerChanged je vyvolána při úpravě aktuálně aktivního dokumentu.

Při vytváření delegáta ActiveDesignerEventHandler identifikujete metodu, která bude zpracovávat událost. Pokud chcete událost přidružit k obslužné rutině události, přidejte do události instanci delegáta. Obslužná rutina události je volána při každém výskytu události, dokud neodeberete delegáta. Další informace o delegátech obslužné rutiny událostí najdete v tématu Zpracování a vyvolávání událostí.

Metody rozšíření

GetMethodInfo(Delegate)

Získá objekt, který představuje metodu reprezentovanou zadaným delegátem.

Platí pro

Viz také