Udostępnij za pośrednictwem


FileCodeModel2.CodeElements Property

Gets a collection of code elements.

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

Syntax

'Declaration
ReadOnly Property CodeElements As CodeElements
'Usage
Dim instance As FileCodeModel2 
Dim value As CodeElements 

value = instance.CodeElements
CodeElements CodeElements { get; }
property CodeElements^ CodeElements {
    CodeElements^ get ();
}
function get CodeElements () : CodeElements

Property Value

Type: EnvDTE.CodeElements
A CodeElements collection.

Implements

FileCodeModel.CodeElements

Examples

Sub CodeElementsExample(ByVal dte As DTE2)

    ' Before running this example, open a code document from a project.
    Try
        Dim fcm As FileCodeModel = _
            dte.ActiveDocument.ProjectItem.FileCodeModel

        ' Find the FileCodeModel's children.
        Dim children As String
        Dim elem As CodeElement
        For Each elem In fcm.CodeElements
            children &= elem.Name & vbCrLf
        Next

        MsgBox(fcm.Parent.Name & _
            " has the following top-level code elements:" & _
            vbCrLf & vbCrLf & children)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
public void CodeElementsExample(DTE2 dte)
{
    // Before running this example, open a code document from 
    // a project.
    try
    {
        FileCodeModel fcm = 
            dte.ActiveDocument.ProjectItem.FileCodeModel;

        // Find the FileCodeModel's children.
        string children = "";
        foreach (CodeElement elem in fcm.CodeElements)
        {
            children += elem.Name + Environment.NewLine;
        }

        MessageBox.Show(fcm.Parent.Name + 
            " has the following top-level code elements:" + 
            Environment.NewLine + Environment.NewLine + children);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework Security

See Also

Reference

FileCodeModel2 Interface

FileCodeModel2 Members

CodeElements Overload

EnvDTE80 Namespace

Other Resources

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