This documentation is archived and is not being maintained.

CodeElement Property (General Extensibility)

Visual Studio .NET 2003

Returns the code element at the TextPoint or EditPoint location.

[Visual Basic .NET]
Public ReadOnly Property CodeElement( _
   ByVal Scope As vsCMElement _
) As CodeElement
[Visual Basic 6]
Property Get CodeElement( _
   ByVal Scope As vsCMElement _
) As CodeElement
HRESULT __stdcall get_CodeElement(
   vsCMElement Scope,
   /* [out, retval] */ CodeElement** retVal
CodeElement CodeElement(
   vsCMElement Scope
) {get;}
[JScript .NET]
public function get CodeElement(
   Scope : vsCMElement
) : CodeElement


Required. A vsCMElement constant indicating the code element with the specified kind that contains the editor location.

Return Value

Returns a CodeElement object.


If the specified code element type is not at the EditPoint/TextPoint location, then CodeElement returns Nothing. CodeElement is a shortcut for TextPoint.Parent.Parent.ProjectItem.CodeModel.CodeElementFromPoint(TextPoint, <scope>)


Sub CodeElementExample()
   Dim fileCM As FileCodeModel
   fileCM = ActiveDocument.ProjectItem.FileCodeModel
   Dim elts As CodeElements
   elts = fileCM.CodeElements
   Dim elt As CodeElement
   Dim i As Integer
   msgbox("about to walk top-level elts ...")
   For i = 1 To fileCM.CodeElements.Count
      elt = elts.Item(i)
      CollapseElt(elt, elts, i)
End Sub

See Also

Applies To: EditPoint Object | TextPoint Object | VirtualPoint Object