ActiveDesignerEventHandler Delegate
Assembly: System (in system.dll)
'Declaration Public Delegate Sub ActiveDesignerEventHandler ( _ sender As Object, _ e As ActiveDesignerEventArgs _ ) 'Usage Dim instance As New ActiveDesignerEventHandler(AddressOf HandlerMethod)
/** @delegate */ public delegate void ActiveDesignerEventHandler ( Object sender, ActiveDesignerEventArgs e )
Not applicable.
Parameters
- sender
The source of the event.
- e
An ActiveDesignerEventArgs that contains the event data.
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 Events and Delegates.
The following example demonstrates registering an ActiveDesignerEventHandler and handling an ActiveDesignerChanged event.
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
public void LinkActiveDesignerEvent(IDesignerEventService eventService)
{
// Registers an event handler for the ActiveDesignerChanged event.
eventService.add_ActiveDesignerChanged(new ActiveDesignerEventHandler(
this.OnActiveDesignerEvent));
} //LinkActiveDesignerEvent
private void OnActiveDesignerEvent(Object sender, ActiveDesignerEventArgs e)
{
// Displays changed designer information on the console.
if (e.get_NewDesigner().get_RootComponent().get_Site() != null) {
Console.WriteLine("Name of the component of the new active designer: "
+ e.get_NewDesigner().get_RootComponent().get_Site().get_Name());
}
Console.WriteLine("Type of the component of the new active designer: "
+ e.get_NewDesigner().get_RootComponentClassName());
if (e.get_OldDesigner().get_RootComponent().get_Site() != null) {
Console.WriteLine("Name of the component of the previously active"
+ " designer: " + e.get_OldDesigner().get_RootComponent().
get_Site().get_Name());
}
Console.WriteLine("Type of the component of the previously active "
+ " designer: " + e.get_OldDesigner().get_RootComponentClassName());
} //OnActiveDesignerEvent
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.