UIHierarchy.UIHierarchyItems 属性

更新:2007 年 11 月

获取表示项的子级的集合。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
ReadOnly Property UIHierarchyItems As UIHierarchyItems
用法
Dim instance As UIHierarchy
Dim value As UIHierarchyItems

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

属性值

类型:EnvDTE.UIHierarchyItems

一个 UIHierarchyItems 集合。

示例

Sub UIHierarchyItemsExample(ByVal dte As DTE2)

    ' NOTE: This example requires a reference to the 
    '       System.Text namespace.

    ' Before running this example, open a project.
    Dim sb As New StringBuilder

    RecurseItems(dte.ToolWindows.SolutionExplorer.UIHierarchyItems, _
        0, sb)

    MsgBox("Solution Explorer contains the following items:" & _
        vbCrLf & vbCrLf & sb.ToString())

End Sub

Sub RecurseItems(ByVal items As UIHierarchyItems, _
    ByVal level As Integer, ByVal sb As StringBuilder)

    Dim item As UIHierarchyItem
    For Each item In items
        ' Add item to the list of names.
        sb.Append(" "c, level * 8)
        sb.Append(item.Name & vbCrLf)

        RecurseItems(item.UIHierarchyItems, level + 1, sb)
    Next

End Sub
public void UIHierarchyItemsExample(DTE2 dte)
{
    // NOTE: This example requires a reference to the 
    //       System.Text namespace.

    // Before running this example, open a project.
    StringBuilder sb = new StringBuilder();

    RecurseItems(dte.ToolWindows.SolutionExplorer.UIHierarchyItems, 
        0, sb);

    MessageBox.Show(
        "Solution Explorer contains the following items:\n\n" + 
        sb.ToString());
}

void RecurseItems(UIHierarchyItems items, int level, StringBuilder sb)
{
    foreach (UIHierarchyItem item in items)
    {
        // Add item to the list of names.
        sb.Append(' ', level * 8);
        sb.Append(item.Name + "\n");

        RecurseItems(item.UIHierarchyItems, level + 1, sb);
    }
}

权限

另请参见

参考

UIHierarchy 接口

UIHierarchy 成员

EnvDTE 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例