Partilhar via


DesignerTransactionCloseEventHandler Delegar

Definição

Representa o método que manipula os eventos TransactionClosed e TransactionClosing de um designer.

public delegate void DesignerTransactionCloseEventHandler(System::Object ^ sender, DesignerTransactionCloseEventArgs ^ e);
public delegate void DesignerTransactionCloseEventHandler(object sender, DesignerTransactionCloseEventArgs e);
public delegate void DesignerTransactionCloseEventHandler(object? sender, DesignerTransactionCloseEventArgs e);
[System.Runtime.InteropServices.ComVisible(true)]
public delegate void DesignerTransactionCloseEventHandler(object sender, DesignerTransactionCloseEventArgs e);
type DesignerTransactionCloseEventHandler = delegate of obj * DesignerTransactionCloseEventArgs -> unit
[<System.Runtime.InteropServices.ComVisible(true)>]
type DesignerTransactionCloseEventHandler = delegate of obj * DesignerTransactionCloseEventArgs -> unit
Public Delegate Sub DesignerTransactionCloseEventHandler(sender As Object, e As DesignerTransactionCloseEventArgs)

Parâmetros

sender
Object

A fonte do evento.

Atributos

Exemplos

O exemplo a seguir demonstra o registro de um DesignerTransactionCloseEventHandler e o tratamento dos TransactionClosing eventos e 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

Comentários

Ao criar um DesignerTransactionCloseEventHandler delegado, você identifica o método que manipulará o evento. Para associar o evento ao manipulador de eventos, adicione uma instância do delegado ao evento. O manipulador de eventos é chamado sempre que o evento ocorre, a menos que você remova o representante. Para obter mais informações sobre delegados do manipulador de eventos, consulte Manipulando e levantando eventos.

Métodos de Extensão

GetMethodInfo(Delegate)

Obtém um objeto que representa o método representado pelo delegado especificado.

Aplica-se a

Confira também