CodeAttachEventStatement Class
TOC
Collapse the table of content
Expand the table of content

CodeAttachEventStatement Class

 

Represents a statement that attaches an event-handler delegate to an event.

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

System.Object
  System.CodeDom.CodeObject
    System.CodeDom.CodeStatement
      System.CodeDom.CodeAttachEventStatement

<SerializableAttribute>
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)>
<ComVisibleAttribute(True)>
Public Class CodeAttachEventStatement
	Inherits CodeStatement

NameDescription
System_CAPS_pubmethodCodeAttachEventStatement()

Initializes a new instance of the CodeAttachEventStatement class.

System_CAPS_pubmethodCodeAttachEventStatement(CodeEventReferenceExpression, CodeExpression)

Initializes a new instance of the CodeAttachEventStatement class using the specified event and delegate.

System_CAPS_pubmethodCodeAttachEventStatement(CodeExpression, String, CodeExpression)

Initializes a new instance of the CodeAttachEventStatement class using the specified object containing the event, event name, and event-handler delegate.

NameDescription
System_CAPS_pubpropertyEndDirectives

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

System_CAPS_pubpropertyEvent

Gets or sets the event to attach an event-handler delegate to.

System_CAPS_pubpropertyLinePragma

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

System_CAPS_pubpropertyListener

Gets or sets the new event-handler delegate to attach to the event.

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

CodeAttachEventStatement can be used to represent a statement that adds an event-handler delegate for an event. The Event property indicates the event to attach the event handler to. The Listener property indicates the event handler to attach.

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 TestMethod.
Dim createDelegate1 As New CodeDelegateCreateExpression(New CodeTypeReference("System.EventHandler"), New CodeThisReferenceExpression(), "TestMethod")

' Attaches an EventHandler delegate pointing to TestMethod to the TestEvent event.
Dim attachStatement1 As New CodeAttachEventStatement(New CodeThisReferenceExpression(), "TestEvent", createDelegate1)

' A Visual Basic code generator produces the following source code for the preceeding example code:

'     AddHandler TestEvent, AddressOf Me.TestMethod

.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:
© 2016 Microsoft