ComponentChangingEventHandler 代理人
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表將處理 ComponentChanging 事件的方法。
public delegate void ComponentChangingEventHandler(System::Object ^ sender, ComponentChangingEventArgs ^ e);
C#
public delegate void ComponentChangingEventHandler(object sender, ComponentChangingEventArgs e);
C#
public delegate void ComponentChangingEventHandler(object? sender, ComponentChangingEventArgs e);
C#
[System.Runtime.InteropServices.ComVisible(true)]
public delegate void ComponentChangingEventHandler(object sender, ComponentChangingEventArgs e);
type ComponentChangingEventHandler = delegate of obj * ComponentChangingEventArgs -> unit
[<System.Runtime.InteropServices.ComVisible(true)>]
type ComponentChangingEventHandler = delegate of obj * ComponentChangingEventArgs -> unit
Public Delegate Sub ComponentChangingEventHandler(sender As Object, e As ComponentChangingEventArgs)
- sender
- Object
事件的來源。
ComponentChangingEventArgs 事件,包含事件資料。
- 屬性
此範例示範註冊 ComponentChangingEventHandler 和處理 ComponentChanging 事件。
public:
void LinkComponentChangingEvent( IComponentChangeService^ changeService )
{
// Registers an event handler for the ComponentChanging event.
changeService->ComponentChanging += gcnew ComponentChangingEventHandler(
this, &ComponentChangingEventHandlerExample::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.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);
}
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
建立 ComponentChangingEventHandler 委派時,必須識別處理事件的方法。 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (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 |