CodeRemoveEventStatement Class
.NET Framework 3.0
Represents a statement that removes an event handler.
Namespace: System.CodeDom
Assembly: System (in system.dll)
Assembly: System (in system.dll)
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public class CodeRemoveEventStatement : CodeStatement
/** @attribute SerializableAttribute() */ /** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ /** @attribute ComVisibleAttribute(true) */ public class CodeRemoveEventStatement extends CodeStatement
SerializableAttribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) ComVisibleAttribute(true) public class CodeRemoveEventStatement extends CodeStatement
Not applicable.
The following example demonstrates use of a CodeRemoveEventStatement to remove a delegate from an event.
// 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 = 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.Object
System.CodeDom.CodeObject
System.CodeDom.CodeStatement
System.CodeDom.CodeRemoveEventStatement
System.CodeDom.CodeObject
System.CodeDom.CodeStatement
System.CodeDom.CodeRemoveEventStatement
Windows 98, Windows Server 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
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: