Eksporter (0) Skriv ut
Vis alt
EN
Dette innholdet er ikke tilgjengelig på ditt språk, men her er den engelske versjonen.

CodeRemoveEventStatement Class

Represents a statement that removes an event handler.

Namespace: System.CodeDom
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.

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

// 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

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

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.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Fellesskapsinnhold

Legg til
Vis:
© 2014 Microsoft