DesignerTransactionCloseEventHandler 代理人
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表 TransactionClosed 處理設計者事件 TransactionClosing 的方法。
public delegate void DesignerTransactionCloseEventHandler(System::Object ^ sender, DesignerTransactionCloseEventArgs ^ e);
[System.Runtime.InteropServices.ComVisible(true)]
public delegate void DesignerTransactionCloseEventHandler(object sender, DesignerTransactionCloseEventArgs e);
public delegate void DesignerTransactionCloseEventHandler(object sender, DesignerTransactionCloseEventArgs e);
[<System.Runtime.InteropServices.ComVisible(true)>]
type DesignerTransactionCloseEventHandler = delegate of obj * DesignerTransactionCloseEventArgs -> unit
type DesignerTransactionCloseEventHandler = delegate of obj * DesignerTransactionCloseEventArgs -> unit
Public Delegate Sub DesignerTransactionCloseEventHandler(sender As Object, e As DesignerTransactionCloseEventArgs)
參數
- sender
- Object
事件的 來源。
- 屬性
範例
以下範例示範註冊 a DesignerTransactionCloseEventHandler 並處理 TransactionClosing 和 TransactionClosed 事件。
public:
void LinkDesignerTransactionCloseEvent( IDesignerHost^ host )
{
// Registers an event handler for the designer TransactionClosing and TransactionClosed events.
host->TransactionClosing += gcnew DesignerTransactionCloseEventHandler(
this, &DesignerTransactionCloseEventHandlerExample::OnTransactionClose );
host->TransactionClosed += gcnew DesignerTransactionCloseEventHandler(
this, &DesignerTransactionCloseEventHandlerExample::OnTransactionClose );
}
private:
void OnTransactionClose( Object^ sender, DesignerTransactionCloseEventArgs^ e )
{
// Displays transaction close information on the console.
if ( e->TransactionCommitted )
{
Console::WriteLine( "Transaction has been committed." );
}
else
{
Console::WriteLine( "Transaction has not yet been committed." );
}
}
public void LinkDesignerTransactionCloseEvent(IDesignerHost host)
{
// Registers an event handler for the designer TransactionClosing and TransactionClosed events.
host.TransactionClosing += new DesignerTransactionCloseEventHandler(this.OnTransactionClose);
host.TransactionClosed += new DesignerTransactionCloseEventHandler(this.OnTransactionClose);
}
private void OnTransactionClose(object sender, DesignerTransactionCloseEventArgs e)
{
// Displays transaction close information on the console.
if( e.TransactionCommitted )
Console.WriteLine("Transaction has been committed.");
else
Console.WriteLine("Transaction has not yet been committed.");
}
Public Sub LinkDesignerTransactionCloseEvent(ByVal host As IDesignerHost)
' Registers an event handler for the designer TransactionClosing
' and TransactionClosed events.
AddHandler host.TransactionClosing, AddressOf Me.OnTransactionClose
AddHandler host.TransactionClosed, AddressOf Me.OnTransactionClose
End Sub
Private Sub OnTransactionClose(ByVal sender As Object, ByVal e As DesignerTransactionCloseEventArgs)
' Displays transaction close information on the console.
If e.TransactionCommitted Then
Console.WriteLine("Transaction has been committed.")
Else
Console.WriteLine("Transaction has not yet been committed.")
End If
End Sub
備註
當你建立 DesignerTransactionCloseEventHandler 代理人時,你就能確定處理事件的方法。 要將事件與你的事件處理器關聯,請將該代理的實例加入事件中。 事件處理程序會在事件發生時被呼叫,除非你移除代理。 欲了解更多關於事件處理代表的資訊,請參閱 「處理與提升事件」。
擴充方法
| 名稱 | Description |
|---|---|
| GetMethodInfo(Delegate) |
取得一個代表指定代理所代表方法的物件。 |