CodeAttachEventStatement クラス

定義

イベント ハンドラーのデリゲートをイベントに結び付けるステートメントを表します。

public ref class CodeAttachEventStatement : System::CodeDom::CodeStatement
public class CodeAttachEventStatement : System.CodeDom.CodeStatement
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeAttachEventStatement : System.CodeDom.CodeStatement
type CodeAttachEventStatement = class
    inherit CodeStatement
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeAttachEventStatement = class
    inherit CodeStatement
Public Class CodeAttachEventStatement
Inherits CodeStatement
継承
CodeAttachEventStatement
属性

次のコード例は、 を CodeAttachEventStatement 使用してイベント ハンドラーをイベントにアタッチする方法を示しています。

// Defines a delegate creation expression that creates an EventHandler delegate pointing to a method named TestMethod.
CodeDelegateCreateExpression^ createDelegate1 = gcnew CodeDelegateCreateExpression( gcnew CodeTypeReference( "System.EventHandler" ),gcnew CodeThisReferenceExpression,"TestMethod" );

// Attaches an EventHandler delegate pointing to TestMethod to the TestEvent event.
CodeAttachEventStatement^ attachStatement1 = gcnew CodeAttachEventStatement( gcnew CodeThisReferenceExpression,"TestEvent",createDelegate1 );

// A C# code generator produces the following source code for the preceeding example code:
//     this.TestEvent += new System.EventHandler(this.TestMethod);
// Defines a delegate creation expression that creates an EventHandler delegate pointing to a method named TestMethod.
CodeDelegateCreateExpression createDelegate1 = new CodeDelegateCreateExpression(
new CodeTypeReference( "System.EventHandler" ), new CodeThisReferenceExpression(), "TestMethod" );
// Attaches an EventHandler delegate pointing to TestMethod to the TestEvent event.
CodeAttachEventStatement attachStatement1 = new CodeAttachEventStatement( new CodeThisReferenceExpression(), "TestEvent", createDelegate1 );

// A C# code generator produces the following source code for the preceeding example code:

//     this.TestEvent += new System.EventHandler(this.TestMethod);
' Defines a delegate creation expression that creates an EventHandler delegate pointing to TestMethod.
Dim createDelegate1 As New CodeDelegateCreateExpression(New CodeTypeReference("System.EventHandler"), New CodeThisReferenceExpression(), "TestMethod")

' Attaches an EventHandler delegate pointing to TestMethod to the TestEvent event.
Dim attachStatement1 As New CodeAttachEventStatement(New CodeThisReferenceExpression(), "TestEvent", createDelegate1)

' A Visual Basic code generator produces the following source code for the preceeding example code:

'     AddHandler TestEvent, AddressOf Me.TestMethod

注釈

CodeAttachEventStatement を使用して、イベントのイベント ハンドラー デリゲートを追加するステートメントを表すことができます。 プロパティは Event 、イベント ハンドラーをアタッチするイベントを示します。 プロパティは Listener 、アタッチするイベント ハンドラーを示します。

コンストラクター

CodeAttachEventStatement()

CodeAttachEventStatement クラスの新しいインスタンスを初期化します。

CodeAttachEventStatement(CodeEventReferenceExpression, CodeExpression)

イベントとデリゲートを指定して、CodeAttachEventStatement クラスの新しいインスタンスを初期化します。

CodeAttachEventStatement(CodeExpression, String, CodeExpression)

イベント、イベント名、およびイベント ハンドラー デリゲートを格納しているオブジェクトを指定して、CodeAttachEventStatement クラスの新しいインスタンスを初期化します。

プロパティ

EndDirectives

終了ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。

(継承元 CodeStatement)
Event

イベント ハンドラー デリゲートを結び付けるイベントを取得または設定します。

LinePragma

コード ステートメントのある行を取得または設定します。

(継承元 CodeStatement)
Listener

イベントに結び付ける新しいイベント ハンドラーのデリゲートを取得または設定します。

StartDirectives

開始ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。

(継承元 CodeStatement)
UserData

現在のオブジェクトのユーザー定義可能なデータを取得します。

(継承元 CodeObject)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象