Condividi tramite


DesignerTransactionCloseEventHandler Delegato

Definizione

Rappresenta il metodo che gestirà gli eventi TransactionClosed e TransactionClosing di una finestra di progettazione.

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)

Parametri

sender
Object

Origine dell'evento.

e
DesignerTransactionCloseEventArgs

Oggetto DesignerTransactionCloseEventArgs che contiene i dati dell'evento.

Attributi

Esempio

Nell'esempio seguente viene illustrata la registrazione di un DesignerTransactionCloseEventHandler oggetto e la gestione degli TransactionClosing eventi 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

Commenti

Quando si crea un delegato DesignerTransactionCloseEventHandler, si identifica il metodo che gestirà l'evento. Per associare l'evento al gestore eventi in uso, aggiungere all'evento un'istanza del delegato. Il gestore eventi viene chiamato ogni volta che si verifica l'evento, a meno che non venga rimosso il delegato. Per altre informazioni sui delegati del gestore eventi, vedere Gestione e generazione di eventi.

Metodi di estensione

GetMethodInfo(Delegate)

Ottiene un oggetto che rappresenta il metodo rappresentato dal delegato specificato.

Si applica a

Vedi anche