Export (0) Print
Expand All
ID
Top
Expand Minimize

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
[C++]
HRESULT __stdcall get_CodeElement(
   vsCMElement Scope,
   /* [out, retval] */ CodeElement** retVal
);
[C#]
CodeElement CodeElement(
   vsCMElement Scope
) {get;}
[JScript .NET]
public function get CodeElement(
   Scope : vsCMElement
) : CodeElement

Parameters

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

Return Value

Returns a CodeElement object.

Remarks

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

Example

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)
   Next
End Sub

See Also

Applies To: EditPoint Object | TextPoint Object | VirtualPoint Object

Show:
© 2014 Microsoft