Export (0) Print
Expand All
Expand Minimize

ComponentRenameEventHandler Delegate

Represents the method that will handle a ComponentRename event.

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

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

Remarks

When you create a ComponentRenameEventHandler 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 ComponentRenameEventHandler and handling the ComponentRename event.

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

Private Sub OnComponentRename(ByVal sender As Object, ByVal e As ComponentRenameEventArgs)
    ' Displays component renamed information on the console.           
    Console.WriteLine(("Type of the component that has been renamed: " + e.Component.GetType().FullName))
    Console.WriteLine(("New name of the component that has been renamed: " + e.NewName))
    Console.WriteLine(("Old name of the component that has been renamed: " + e.OldName))
End Sub

[C#] 
public void LinkComponentRenameEvent(IComponentChangeService changeService)
{
    // Registers an event handler for the ComponentRename event.
    changeService.ComponentRename += new ComponentRenameEventHandler(this.OnComponentRename);            
}

private void OnComponentRename(object sender, ComponentRenameEventArgs e)
{
    // Displayss component renamed information on the console.           
    Console.WriteLine("Type of the component that has been renamed: "+e.Component.GetType().FullName);                  
    Console.WriteLine("New name of the component that has been renamed: "+e.NewName);
    Console.WriteLine("Old name of the component that has been renamed: "+e.OldName);
}

[C++] 
public:

    void LinkComponentRenameEvent(IComponentChangeService* changeService)
    {
        // Registers an event handler for the ComponentRename event.
        changeService->ComponentRename +=
            new ComponentRenameEventHandler(this, &ComponentRenameEventHandlerExample::OnComponentRename);
    }

private:

    void OnComponentRename(Object* /*sender*/, ComponentRenameEventArgs* e)
    {
        // Displayss component renamed information on the console.
        Console::WriteLine(S"Type of the component that has been renamed: {0}", e->Component->GetType()->FullName);
        Console::WriteLine(S"New name of the component that has been renamed: {0}", e->NewName);
        Console::WriteLine(S"Old name of the component that has been renamed: {0}", e->OldName);
    }

[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 | ComponentRename | ComponentRenameEventArgs

Show:
© 2014 Microsoft