CodeRemoveEventStatement クラス
アセンブリ: System (system.dll 内)

<SerializableAttribute> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public Class CodeRemoveEventStatement Inherits CodeStatement
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public class CodeRemoveEventStatement : CodeStatement
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] [ComVisibleAttribute(true)] public ref class CodeRemoveEventStatement : public CodeStatement

CodeRemoveEventStatement を使用して、イベントのイベント ハンドラを削除するステートメントを表すことができます。
Event プロパティは、イベント ハンドラが削除されるイベントを指定します。Listener プロパティは、削除するイベント ハンドラを指定します。

CodeRemoveEventStatement を使用して、イベントからデリゲートを削除する例を次に示します。
' Creates a delegate of type System.EventHandler pointing to a method named OnMouseEnter. Dim mouseEnterDelegate As New CodeDelegateCreateExpression(New CodeTypeReference("System.EventHandler"), New CodeThisReferenceExpression(), "OnMouseEnter") ' Creates a remove event statement that removes the delegate from the TestEvent event. Dim removeEvent1 As New CodeRemoveEventStatement(New CodeThisReferenceExpression(), "TestEvent", mouseEnterDelegate) ' A Visual Basic code generator produces the following source code for the preceeding example code: ' RemoveHandler TestEvent, AddressOf Me.OnMouseEnter
// Creates a delegate of type System.EventHandler pointing to a method named OnMouseEnter. CodeDelegateCreateExpression mouseEnterDelegate = new CodeDelegateCreateExpression( new CodeTypeReference("System.EventHandler"), new CodeThisReferenceExpression(), "OnMouseEnter" ); // Creates a remove event statement that removes the delegate from the TestEvent event. CodeRemoveEventStatement removeEvent1 = new CodeRemoveEventStatement( new CodeThisReferenceExpression(), "TestEvent", mouseEnterDelegate ); // A C# code generator produces the following source code for the preceeding example code: // this.TestEvent -= new System.EventHandler(this.OnMouseEnter);
// Creates a delegate of type System.EventHandler pointing to a method named OnMouseEnter. CodeDelegateCreateExpression^ mouseEnterDelegate = gcnew CodeDelegateCreateExpression( gcnew CodeTypeReference( "System.EventHandler" ),gcnew CodeThisReferenceExpression,"OnMouseEnter" ); // Creates a remove event statement that removes the delegate from the TestEvent event. CodeRemoveEventStatement^ removeEvent1 = gcnew CodeRemoveEventStatement( gcnew CodeThisReferenceExpression,"TestEvent",mouseEnterDelegate ); // A C# code generator produces the following source code for the preceeding example code: // this.TestEvent -= new System.EventHandler(this.OnMouseEnter);
// Creates a delegate of type System.EventHandler pointing // to a method named OnMouseEnter. CodeDelegateCreateExpression mouseEnterDelegate = new CodeDelegateCreateExpression(new CodeTypeReference( "System.EventHandler"), new CodeThisReferenceExpression() , "OnMouseEnter"); // Creates a remove event statement that removes the delegate // from the TestEvent event. CodeRemoveEventStatement removeEvent1 = new CodeRemoveEventStatement(new CodeThisReferenceExpression() , "TestEvent", mouseEnterDelegate); // A VJ# code generator produces the following source code for // the preceeding example code: // this.TestEvent -= new System.EventHandler(this.OnMouseEnter);

System.CodeDom.CodeObject
System.CodeDom.CodeStatement
System.CodeDom.CodeRemoveEventStatement


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- CodeRemoveEventStatement クラスのページへのリンク