Export (0) Print
Expand All

UIHierarchy.UIHierarchyItems Property

Gets a collection representing children of the item.

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

UIHierarchyItems UIHierarchyItems { get; }

Property Value

Type: EnvDTE.UIHierarchyItems
A UIHierarchyItems collection.

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

Show:
© 2014 Microsoft