Freigeben über


DesignerTransactionCloseEventHandler-Delegat

Stellt die Methode dar, die das TransactionClosed-Ereignis und das TransactionClosing-Ereignis eines Designers behandelt.

Namespace: System.ComponentModel.Design
Assembly: System (in system.dll)

Syntax

'Declaration
<ComVisibleAttribute(True)> _
Public Delegate Sub DesignerTransactionCloseEventHandler ( _
    sender As Object, _
    e As DesignerTransactionCloseEventArgs _
)
'Usage
Dim instance As New DesignerTransactionCloseEventHandler(AddressOf HandlerMethod)
[ComVisibleAttribute(true)] 
public delegate void DesignerTransactionCloseEventHandler (
    Object sender,
    DesignerTransactionCloseEventArgs e
)
[ComVisibleAttribute(true)] 
public delegate void DesignerTransactionCloseEventHandler (
    Object^ sender, 
    DesignerTransactionCloseEventArgs^ e
)
/** @delegate */
/** @attribute ComVisibleAttribute(true) */ 
public delegate void DesignerTransactionCloseEventHandler (
    Object sender, 
    DesignerTransactionCloseEventArgs e
)
JScript unterstützt die Verwendung von Delegaten, aber nicht die Deklaration von neuen Delegaten.

Parameter

  • sender
    Die Quelle des Ereignisses.

Hinweise

Beim Erstellen eines DesignerTransactionCloseEventHandler-Delegaten bestimmen Sie die Methode für die Ereignisbehandlung. Um dem Ereignishandler das Ereignis zuzuordnen, fügen Sie dem Ereignis eine Instanz des Delegaten hinzu. Der Ereignishandler wird bei jedem Eintreten des Ereignisses aufgerufen, sofern der Delegat nicht entfernt wird. Weitere Informationen über Ereignishandlerdelegaten finden Sie unter Ereignisse und Delegaten.

Hinweis

Das auf diese Klasse angewendete HostProtectionAttribute-Attribut besitzt den Resources-Eigenschaftenwert SharedState. Das HostProtectionAttribute hat keine Auswirkungen auf Desktopanwendungen (die normalerweise durch Doppelklicken auf ein Symbol, Eingeben eines Befehls oder eines URL in einem Browser gestartet werden). Weitere Informationen finden Sie unter der HostProtectionAttribute-Klasse oder unter SQL Server-Programmierung und Hostschutzattribute.

Beispiel

Im folgenden Beispiel wird die Registrierung eines DesignerTransactionCloseEventHandler sowie die Behandlung des TransactionClosing-Ereignisses und des TransactionClosed-Ereignisses veranschaulicht.

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
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:
   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.add_TransactionClosing(new DesignerTransactionCloseEventHandler(
        this.OnTransactionClose));
    host.add_TransactionClosed(new DesignerTransactionCloseEventHandler(
        this.OnTransactionClose));
} //LinkDesignerTransactionCloseEvent

private void OnTransactionClose(Object sender, 
    DesignerTransactionCloseEventArgs e)
{
    // Displays transaction close information on the console.           
    if (e.get_TransactionCommitted()) {
        Console.WriteLine("Transaction has been committed.");
    }
    else {
        Console.WriteLine("Transaction has not yet been committed.");
    }
} //OnTransactionClose 

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

System.ComponentModel.Design-Namespace
IDesignerHost