This documentation is archived and is not being maintained.
CodeAttachEventStatement Class
Visual Studio 2010
Represents a statement that attaches an event-handler delegate to an event.
System::Object
System.CodeDom::CodeObject
System.CodeDom::CodeStatement
System.CodeDom::CodeAttachEventStatement
System.CodeDom::CodeObject
System.CodeDom::CodeStatement
System.CodeDom::CodeAttachEventStatement
Assembly: System (in System.dll)
The CodeAttachEventStatement type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CodeAttachEventStatement() | Initializes a new instance of the CodeAttachEventStatement class. |
![]() | CodeAttachEventStatement(CodeEventReferenceExpression, CodeExpression) | Initializes a new instance of the CodeAttachEventStatement class using the specified event and delegate. |
![]() | CodeAttachEventStatement(CodeExpression, String, CodeExpression) | Initializes a new instance of the CodeAttachEventStatement class using the specified object containing the event, event name, and event-handler delegate. |
| Name | Description | |
|---|---|---|
![]() | EndDirectives | Gets a CodeDirectiveCollection object that contains end directives. (Inherited from CodeStatement.) |
![]() | Event | Gets or sets the event to attach an event-handler delegate to. |
![]() | LinePragma | Gets or sets the line on which the code statement occurs. (Inherited from CodeStatement.) |
![]() | Listener | Gets or sets the new event-handler delegate to attach to the event. |
![]() | StartDirectives | Gets a CodeDirectiveCollection object that contains start directives. (Inherited from CodeStatement.) |
![]() | UserData | Gets the user-definable data for the current object. (Inherited from CodeObject.) |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
The following example code demonstrates use of a CodeAttachEventStatement to attach an event handler with an event.
// 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);
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show:
