This documentation is archived and is not being maintained.

CodeMemberEvent Class

Represents a declaration for an event of a type.

For a list of all members of this type, see CodeMemberEvent Members.

System.Object
   System.CodeDom.CodeObject
      System.CodeDom.CodeTypeMember
         System.CodeDom.CodeMemberEvent

[Visual Basic]
<Serializable>
<ClassInterface(ClassInterfaceType.AutoDispatch)>
<ComVisible(True)>
Public Class CodeMemberEvent
   Inherits CodeTypeMember
[C#]
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class CodeMemberEvent : CodeTypeMember
[C++]
[Serializable]
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public __gc class CodeMemberEvent : public CodeTypeMember
[JScript]
public
   Serializable
 ClassInterface(ClassInterfaceType.AutoDispatch)
 ComVisible(true)
class CodeMemberEvent extends CodeTypeMember

Thread Safety

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

Remarks

CodeMemberEvent can be used to represent event members of a type. CodeMemberEvent has properties to indicate the data type of the event, whether it privately implements a data type, and what interface types, if any, the member event implements.

Example

[Visual Basic, C#, C++] This example demonstrates use of a CodeMemberEvent to declare an event that takes a System.EventHandler delegate:

[Visual Basic] 
' Declares an event that accepts a delegate type of System.EventHandler.
Dim event1 As New CodeMemberEvent()
' Sets a name for the event.
event1.Name = "TestEvent"
' Sets the type of event.
event1.Type = New CodeTypeReference("System.EventHandler")

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

'     Private Event TestEvent As System.EventHandler

[C#] 
// Declares an event that accepts a delegate type of System.EventHandler.
CodeMemberEvent event1 = new CodeMemberEvent();
// Sets a name for the event.
event1.Name = "TestEvent";
// Sets the type of event.
event1.Type = new CodeTypeReference("System.EventHandler");

// A C# code generator produces the following source code for the preceeding example code:

//    private event System.EventHandler TestEvent;

[C++] 
// Declares an event that accepts a delegate type of System.EventHandler.
CodeMemberEvent* event1 = new CodeMemberEvent();
// Sets a name for the event.
event1->Name = S"TestEvent";
// Sets the type of event.
event1->Type = new CodeTypeReference(S"System.EventHandler");

// A C# code generator produces the following source code for the preceeding example code:

//    private event System.EventHandler TestEvent;

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.CodeDom

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

CodeMemberEvent Members | System.CodeDom Namespace

Show: