ComponentRenameEventHandler 代理人
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表將處理 ComponentRename 事件的方法。
public delegate void ComponentRenameEventHandler(System::Object ^ sender, ComponentRenameEventArgs ^ e);
C#
public delegate void ComponentRenameEventHandler(object sender, ComponentRenameEventArgs e);
C#
public delegate void ComponentRenameEventHandler(object? sender, ComponentRenameEventArgs e);
C#
[System.Runtime.InteropServices.ComVisible(true)]
public delegate void ComponentRenameEventHandler(object sender, ComponentRenameEventArgs e);
type ComponentRenameEventHandler = delegate of obj * ComponentRenameEventArgs -> unit
[<System.Runtime.InteropServices.ComVisible(true)>]
type ComponentRenameEventHandler = delegate of obj * ComponentRenameEventArgs -> unit
Public Delegate Sub ComponentRenameEventHandler(sender As Object, e As ComponentRenameEventArgs)
- sender
- Object
事件的來源。
ComponentRenameEventArgs,其中包含事件資料。
- 屬性
下列範例示範如何 ComponentRenameEventHandler 註冊 和處理 ComponentRename 事件。
public:
void LinkComponentRenameEvent( IComponentChangeService^ changeService )
{
// Registers an event handler for the ComponentRename event.
changeService->ComponentRename += gcnew ComponentRenameEventHandler(
this, &ComponentRenameEventHandlerExample::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.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);
}
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
建立 ComponentRenameEventHandler 委派時,必須識別處理事件的方法。 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (Instance) 加入至事件。 除非您移除委派,否則每當事件發生時就會呼叫事件處理常式。 如需事件處理程式委派的詳細資訊,請參閱 處理和引發事件。
Get |
取得表示特定委派所代表之方法的物件。 |
產品 | 版本 |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |