デザイナの TransactionClosed イベントと TransactionClosing イベントを処理するメソッドを表します。
名前空間: System.ComponentModel.Design
アセンブリ: System (system.dll 内)
構文
'宣言
<ComVisibleAttribute(True)> _
Public Delegate Sub DesignerTransactionCloseEventHandler ( _
sender As Object, _
e As DesignerTransactionCloseEventArgs _
)
'使用
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 では、デリゲートは使用できますが、新規に宣言することはできません。
パラメータ
- sender
イベントのソース。
- e
イベント データを格納している DesignerTransactionCloseEventArgs。
解説
DesignerTransactionCloseEventHandler デリゲートを作成する場合は、イベントを処理するメソッドを識別してください。イベントをイベント ハンドラに関連付けるには、デリゲートのインスタンスをイベントに追加します。デリゲートを削除しない限り、そのイベントが発生すると常にイベント ハンドラが呼び出されます。イベント ハンドラ デリゲートの詳細については、「イベントとデリゲート」を参照してください。
注意
このクラスに適用される HostProtectionAttribute 属性の Resources プロパティの値は、SharedState です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的には、アイコンをダブルクリック、コマンドを入力、またはブラウザに URL を入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラスのトピックまたは「SQL Server プログラミングとホスト保護属性」を参照してください。
使用例
DesignerTransactionCloseEventHandler の登録と TransactionClosing と TransactionClosed の各イベントの処理の例を次に示します。
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
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0