Export (0) Print
Expand All
Expand Minimize

ActiveDesignerEventHandler Delegate

Represents the method that will handle the ActiveDesignerChanged event.

Namespace: System.ComponentModel.Design
Assembly: System (in system.dll)

public delegate void ActiveDesignerEventHandler (
	Object sender,
	ActiveDesignerEventArgs e
)
/** @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 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 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.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft