Export (0) Print
Expand All

FileCodeModel2.CodeElements Property

Gets a collection of code elements.

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

CodeElements CodeElements { get; }

Property Value

Type: EnvDTE.CodeElements
A CodeElements collection.

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

Show:
© 2014 Microsoft