Represents the method that will handle the ActiveDesignerChanged event.
[Visual Basic] <Serializable> Public Delegate Sub ActiveDesignerEventHandler( _ ByVal sender As Object, _ ByVal e As ActiveDesignerEventArgs _ ) [C#] [Serializable] public delegate void ActiveDesignerEventHandler( object sender, ActiveDesignerEventArgs e ); [C++] [Serializable] public __gc __delegate void ActiveDesignerEventHandler( Object* sender, ActiveDesignerEventArgs* e );
[JScript] In JScript, you can use the delegates in the .NET Framework, but you cannot define your own.
The declaration of your event handler must have the same parameters as the ActiveDesignerEventHandler delegate declaration.
The ActiveDesignerChanged event is raised when the currently active document has been modified.
When you create an ActiveDesignerEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see
[Visual Basic, C#, C++] The following example demonstrates registering an ActiveDesignerEventHandler and handling an ActiveDesignerChanged event.
[Visual Basic] 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 Not (e.NewDesigner.RootComponent.Site Is 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 Not (e.OldDesigner.RootComponent.Site Is 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 [C#] 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); } [C++] 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 != 0 ) Console::WriteLine(S"Name of the component of the new active designer: {0}", e->NewDesigner->RootComponent->Site->Name); Console::WriteLine(S"Type of the component of the new active designer: {0}", e->NewDesigner->RootComponentClassName); if( e->OldDesigner->RootComponent->Site != 0 ) Console::WriteLine(S"Name of the component of the previously active designer: {0}", e->OldDesigner->RootComponent->Site->Name); Console::WriteLine(S"Type of the component of the previously active designer: {0}", e->OldDesigner->RootComponentClassName); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Namespace: System.ComponentModel.Design
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
System.ComponentModel.Design Namespace | ActiveDesignerEventArgs | ActiveDesignerChanged