共用方式為


FileCodeModel2.CodeElements 屬性

取得程式碼項目的集合。

命名空間:  EnvDTE80
組件:  EnvDTE80 (在 EnvDTE80.dll 中)

語法

'宣告
ReadOnly Property CodeElements As CodeElements
    Get
CodeElements CodeElements { get; }
property CodeElements^ CodeElements {
    CodeElements^ get ();
}
abstract CodeElements : CodeElements
function get CodeElements () : CodeElements

屬性值

型別:EnvDTE.CodeElements
CodeElements 集合。

實作

FileCodeModel.CodeElements

範例

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 安全性

請參閱

參考

FileCodeModel2 介面

CodeElements 多載

EnvDTE80 命名空間

其他資源

HOW TO:編譯和執行 Automation 物件模型程式碼範例