Share via


CodeModelEventsClass.ElementAdded Event

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Raised when a CodeElement object has been created. The new object is passed to the event handler.

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

Syntax

'Declaration
Public Overridable Event ElementAdded As _dispCodeModelEvents_ElementAddedEventHandler
public virtual event _dispCodeModelEvents_ElementAddedEventHandler ElementAdded
public:
virtual   event _dispCodeModelEvents_ElementAddedEventHandler^ ElementAdded {
    void add (_dispCodeModelEvents_ElementAddedEventHandler^ value);
    void remove (_dispCodeModelEvents_ElementAddedEventHandler^ value);
}
abstract ElementAdded : IEvent<_dispCodeModelEvents_ElementAddedEventHandler,
    EventArgs>
override ElementAdded : IEvent<_dispCodeModelEvents_ElementAddedEventHandler,
    EventArgs>
JScript does not support events.

Implements

_dispCodeModelEvents_Event.ElementAdded

Remarks

Although the object containing the new element is changed by the addition, no events are raised by the parent object. For example, if a parameter is added to a function, the ElementAdded event is raised for the new CodeParameter object. No events are raised for the CodeFunction object that contains it.

Note

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

Examples

Dim WithEvents oCodeModelEvents As EnvDTE80.CodeModelEvents
Public Sub OnCodeElementAdded(ByVal NewElement As EnvDTE.CodeElement) _
  Handles oCodeModelEvents.ElementAdded
    MsgBox(NewElement.Name + "(Kind=" + Str(NewElement.Kind) + ") was _
      added.")
End Sub

.NET Framework Security

See Also

Reference

CodeModelEventsClass Class

EnvDTE80 Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples

Discovering Code by Using the Code Model (Visual Basic)

Discovering Code by Using the Code Model (Visual C#)