CodeRemoveEventStatement Class

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Represents a statement that removes an event handler.

Namespace:   System.CodeDom
Assembly:  System (in System.dll)

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

[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
public class CodeRemoveEventStatement : CodeStatement

NameDescription
System_CAPS_pubmethodCodeRemoveEventStatement()

Initializes a new instance of the CodeRemoveEventStatement class.

System_CAPS_pubmethodCodeRemoveEventStatement(CodeEventReferenceExpression, CodeExpression)

Initializes a new instance of the CodeRemoveEventStatement class with the specified event and event handler.

System_CAPS_pubmethodCodeRemoveEventStatement(CodeExpression, String, CodeExpression)

Initializes a new instance of the CodeRemoveEventStatement class using the specified target object, event name, and event handler.

NameDescription
System_CAPS_pubpropertyEndDirectives

Gets a CodeDirectiveCollection object that contains end directives.(Inherited from CodeStatement.)

System_CAPS_pubpropertyEvent

Gets or sets the event to remove a listener from.

System_CAPS_pubpropertyLinePragma

Gets or sets the line on which the code statement occurs. (Inherited from CodeStatement.)

System_CAPS_pubpropertyListener

Gets or sets the event handler to remove.

System_CAPS_pubpropertyStartDirectives

Gets a CodeDirectiveCollection object that contains start directives.(Inherited from CodeStatement.)

System_CAPS_pubpropertyUserData

Gets the user-definable data for the current object.(Inherited from CodeObject.)

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

CodeRemoveEventStatement can be used to represent a statement that removes an event handler for an event.

The Event property specifies the event to remove the event handler from. The Listener property specifies the event handler to remove.

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);

.NET Framework
Available since 1.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: