DesignerTransactionCloseEventHandler 委托

定义

表示处理设计器的 TransactionClosedTransactionClosing 事件的方法。

C#
public delegate void DesignerTransactionCloseEventHandler(object sender, DesignerTransactionCloseEventArgs e);
C#
public delegate void DesignerTransactionCloseEventHandler(object? sender, DesignerTransactionCloseEventArgs e);
C#
[System.Runtime.InteropServices.ComVisible(true)]
public delegate void DesignerTransactionCloseEventHandler(object sender, DesignerTransactionCloseEventArgs e);

参数

sender
Object

事件源。

属性

示例

以下示例演示如何注册 DesignerTransactionCloseEventHandler 并处理 TransactionClosingTransactionClosed 事件。

C#
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.");
}

注解

创建 DesignerTransactionCloseEventHandler 委托时,需要标识将处理该事件的方法。 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。 除非移除了该委托,否则每当发生该事件时就会调用事件处理程序。 有关事件处理程序委托的详细信息,请参阅 处理和引发事件

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。

适用于

产品 版本
.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

另请参阅