Export (0) Print
Expand All
Expand Minimize

DesignerEventHandler Delegate

Represents the method that will handle the DesignerCreated and DesignerDisposed events that are raised when a document is created or disposed of.

[Visual Basic]
<Serializable>
Public Delegate Sub DesignerEventHandler( _
   ByVal sender As Object, _
   ByVal e As DesignerEventArgs _
)
[C#]
[Serializable]
public delegate void DesignerEventHandler(
   object sender,
   DesignerEventArgs e
);
[C++]
[Serializable]
public __gc __delegate void DesignerEventHandler(
   Object* sender,
   DesignerEventArgs* e
);

[JScript] In JScript, you can use the delegates in the .NET Framework, but you cannot define your own.

Parameters [Visual Basic, C#, C++]

The declaration of your event handler must have the same parameters as the DesignerEventHandler delegate declaration.

sender
The source of the event.
e
A DesignerEventArgs that contains the event data.

Remarks

When you create a DesignerEventHandler 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.

Example

[Visual Basic, C#, C++] The following example demonstrates registering a DesignerEventHandler and handling the DesignerCreated and DesignerDisposed events.

[Visual Basic] 
Public Sub LinkDesignerEvent(ByVal eventService As IDesignerEventService)
    ' Registers an event handler for the DesignerCreated and DesignerDisposed events.
    AddHandler eventService.DesignerCreated, AddressOf Me.OnDesignerEvent
    AddHandler eventService.DesignerDisposed, AddressOf Me.OnDesignerEvent
End Sub

Private Sub OnDesignerEvent(ByVal sender As Object, ByVal e As DesignerEventArgs)
    ' Displays designer event information on the console.
    Console.WriteLine(("Name of the root component of the created or disposed designer: " + e.Designer.RootComponentClassName))
End Sub

[C#] 
public void LinkDesignerEvent(IDesignerEventService eventService)
{                                   
    // Registers an event handler for the DesignerCreated and DesignerDisposed events.
    eventService.DesignerCreated += new DesignerEventHandler(this.OnDesignerEvent);
    eventService.DesignerDisposed += new DesignerEventHandler(this.OnDesignerEvent);            
}

private void OnDesignerEvent(object sender, DesignerEventArgs e)
{
    // Displays designer event information on the console.
    Console.WriteLine("Name of the root component of the created or disposed designer: "+e.Designer.RootComponentClassName);
}

[C++] 
public:

    void LinkDesignerEvent(IDesignerEventService* eventService)
    {
        // Registers an event handler for the DesignerCreated and DesignerDisposed events.
        eventService->DesignerCreated += new DesignerEventHandler(this, &DesignerEventHandlerExample::OnDesignerEvent);
        eventService->DesignerDisposed += new DesignerEventHandler(this, &DesignerEventHandlerExample::OnDesignerEvent);
    }

private:

    void OnDesignerEvent(Object* /*sender*/, DesignerEventArgs* e)
    {
        // Displays designer event information on the console.
        Console::WriteLine(S"Name of the root component of the created or disposed designer: {0}", +e->Designer->RootComponentClassName);
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

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)

See Also

System.ComponentModel.Design Namespace | DesignerEventArgs

Show:
© 2014 Microsoft