This documentation is archived and is not being maintained.

ComponentChangingEventHandler Delegate

Represents the method that will handle a ComponentChanging event.

[Visual Basic]
<Serializable>
<ComVisible(True)>
Public Delegate Sub ComponentChangingEventHandler( _
   ByVal sender As Object, _
   ByVal e As ComponentChangingEventArgs _
)
[C#]
[Serializable]
[ComVisible(true)]
public delegate void ComponentChangingEventHandler(
   object sender,
   ComponentChangingEventArgs e
);
[C++]
[Serializable]
[ComVisible(true)]
public __gc __delegate void ComponentChangingEventHandler(
   Object* sender,
   ComponentChangingEventArgs* 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 ComponentChangingEventHandler delegate declaration.

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

Remarks

When you create a ComponentChangingEventHandler 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++] This example demonstrates registering a ComponentChangingEventHandler and handling the ComponentChanging event.

[Visual Basic] 
Public Sub LinkComponentChangingEvent(ByVal changeService As IComponentChangeService)
    ' Registers an event handler for the ComponentChanging event.
    AddHandler changeService.ComponentChanging, AddressOf Me.OnComponentChanging
End Sub

Private Sub OnComponentChanging(ByVal sender As Object, ByVal e As ComponentChangingEventArgs)
    ' Displays changing component information on the console.
    Console.WriteLine(("Type of the component that is about to change: " + e.Component.GetType().FullName))
    Console.WriteLine(("Name of the member of the component that is about to change: " + e.Member.Name))
End Sub

[C#] 
public void LinkComponentChangingEvent(IComponentChangeService changeService)
{
    // Registers an event handler for the ComponentChanging event.
    changeService.ComponentChanging += new ComponentChangingEventHandler(this.OnComponentChanging);            
}

private void OnComponentChanging(object sender, ComponentChangingEventArgs e)
{
    // Displays changing component information on the console.
    Console.WriteLine("Type of the component that is about to change: "+e.Component.GetType().FullName);      
    Console.WriteLine("Name of the member of the component that is about to change: "+e.Member.Name);                        
}

[C++] 
public:

    void LinkComponentChangingEvent(IComponentChangeService* changeService)
    {
        // Registers an event handler for the ComponentChanging event.
        changeService->ComponentChanging += new ComponentChangingEventHandler(this, &ComponentChangingEventHandlerExample::OnComponentChanging);
    }

private:

    void OnComponentChanging(Object* /*sender*/, ComponentChangingEventArgs* e)
    {
        // Displays changing component information on the console.
        Console::WriteLine(S"Type of the component that is about to change: ", e->Component->GetType()->FullName);
        Console::WriteLine(S"Name of the member of the component that is about to change: {0}", e->Member->Name);
    }

[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 | ComponentChanging | ComponentChanged | ComponentChangingEventArgs | IComponentChangeService

Show: