We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

CodeEvent Interface

Models a code event element.

Namespace:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

public interface CodeEvent

The CodeEvent type exposes the following members.

Public propertyAccessGets or sets a value that determines how a code event element may be accessed by other code.
Public propertyAdderGets or sets the event listeners.
Public propertyAttributesGets a CodeElements collection of attributes for this code event element.
Public propertyChildrenGets a collection of objects contained within this CodeEvent.
Public propertyCollectionGets a CodeElements collection.
Public propertyCommentGets or sets a header comment associated with the code event element.
Public propertyDocCommentGets or sets a documentation comment associated with the code event element.
Public propertyDTEGets the top-level extensibility object.
Public propertyEndPointGets the location in the source file marked as an end of the code event element.
Public propertyExtenderGets the requested Extender if it is available for this CodeElement object.
Public propertyExtenderCATIDGets the Extender category ID (CATID) for the object.
Public propertyExtenderNamesGets a list of available Extenders for the object.
Public propertyFullNameGets a fully-qualified name of the specified CodeEvent object.
Public propertyInfoLocationGets the capabilities of the code model.
Public propertyIsCodeTypeGets whether the CodeEvent is a CodeType.
Public propertyIsPropertyStyleEventGets a value indicating whether the event has separate methods for adding/ removing events and throwing exceptions.
Public propertyIsSharedGets of sets the shared (static) status of the event.
Public propertyKindGets the type of the code element.
Public propertyLanguageGets the programming language used to author the code.
Public propertyNameGets or sets the name of the CodeEvent object.
Public propertyOverrideKindGets of sets the override modifiers on a code event.
Public propertyParentGets the immediate parent object of the CodeEvent object.
Public propertyProjectItemGets the ProjectItem object associated with the CodeEvent object.
Public propertyPrototypeGets a string containing the description of a code event element.
Public propertyRemoverGets or sets the event listeners.
Public propertyStartPointGets the location in the source file marked as a beginning of the code event element.
Public propertyThrowerGets or sets CodeFunction object.
Public propertyTypeGets or sets the type of the CodeTypeReference object.

Public methodAddAttributeCreates a new attribute code construct and inserts the code in the correct location.
Public methodGetEndPointGets a TextPoint object that marks the end of the code event element.
Public methodGetStartPointGets a TextPoint object that marks the beginning of the code event element.

This object is derived from the CodeElement object.


The values of code model elements such as classes, structs, functions, attributes, delegates, and so forth can be non-deterministic after making certain kinds of edits, meaning that their values cannot be relied upon to always remain the same. For more information, see the section Code Model Element Values Can Change in Discovering Code by Using the Code Model (Visual Basic).

The following example demonstrates how to use the CodeEvent object.

To test this property:

  1. Open the target project and select the code event element by placing the cursor on the event object.

  2. Run the add-in.

public static void CodeEventExample(EnvDTE80.DTE2 dte)
    TextSelection objTextSel;
    EnvDTE80.CodeEvent codeEvent;
    objTextSel = (TextSelection)dte.ActiveDocument.Selection;
    codeEvent = (EnvDTE80.CodeEvent)objTextSel. _

    MessageBox.Show("\nAccess property: " +
                    codeEvent.Access, "Testing CodeEvent");