방법: 솔루션 탐색기 제어

Visual Studio의 추가 기능은 Visual Studio 2013에서 사용되지 않습니다. 추가 기능을 VSPackage 확장으로 업그레이드하는 것이 좋습니다. 업그레이드에 대한 자세한 내용은 FAQ: VSPackage 확장으로 추가 기능 변환 을 참조하십시오.

솔루션 탐색기는 솔루션의 프로젝트와 각 프로젝트의 항목을 비롯하여 솔루션의 내용을 표시하는 Visual Studio IDE(통합 개발 환경)의 도구 창입니다. Visual Studio의 다른 도구 창과 마찬가지로 크기, 위치 및 도킹 또는 부동성 여부와 같은 실제 매개 변수들을 제어할 수 있습니다. 이 도구 창과 기타 Visual Studio 도구 창을 조작하는 방법에 대한 자세한 내용은 방법: 창 특성 변경을 참조하십시오.

솔루션 탐색기에는 고유한 자동화 개체가 없지만 UIHierarchy를 사용하면 어느 정도까지는 그 계층 구조의 내용을 제어할 수 있습니다. 솔루션에서 프로젝트와 프로젝트 항목을 제어하려면 프로젝트 자동화 모델을 사용해야 합니다. 자세한 내용은 프로젝트 및 솔루션 제어을 참조하십시오.

참고

표시되는 대화 상자와 메뉴 명령은 활성 설정이나 버전에 따라 도움말에서 설명하는 것과 다를 수 있습니다.이러한 절차는 일반 개발 설정을 사용하여 개발되었습니다.설정을 변경하려면 도구 메뉴에서 설정 가져오기 및 내보내기를 선택합니다.자세한 내용은 Visual Studio에서 개발 설정 사용자 지정을 참조하십시오.

UIHierarchy를 사용하여 솔루션 탐색기를 제어하려면

  1. 솔루션 탐색기가 아직 표시되어 있지 않으면 보기 메뉴에서 솔루션 탐색기를 클릭합니다.

  2. 추가 기능 프로젝트 같이 요소의 수가 많은 프로젝트를 엽니다.

  3. 솔루션 탐색기에서 적어도 두 개 이상의 하위 노드가 있는 노드를 클릭합니다.

  4. 다음 코드를 실행합니다.

예제

이 예제에서는 UIHierarchy를 사용하여 솔루션 탐색기를 조작하는 방법을 보여 줍니다.

Imports System.Text
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE100Public Sub OnConnection(ByVal application As Object, ByVal _
  connectMode As ext_ConnectMode, ByVal addInInst As Object, _
  ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    ' Pass the applicationObject member variable to the code example.
    slnExplUIHierarchyExample(_applicationObject)
End Sub

Sub slnExplUIHierarchyExample(ByVal dte As DTE2)
    Dim UIH As UIHierarchy = dte.ToolWindows.SolutionExplorer
    ' Requires a reference to System.Text.
    ' Set a reference to the first level nodes in Solution Explorer. 
    ' Automation collections are one-based.
    Dim UIHItem As UIHierarchyItem = UIH.UIHierarchyItems.Item(1)
    Dim file As UIHierarchyItem
    Dim sb As New StringBuilder

    ' Iterate through first level nodes.
    For Each file In UIHItem.UIHierarchyItems
        sb.AppendLine(file.Name)
        ' Iterate through second level nodes (if they exist).
        Dim subitem As UIHierarchyItem
        For Each subitem In file.UIHierarchyItems
            sb.AppendLine("   " & subitem.Name)
            ' Iterate through third level nodes (if they exist).
            Dim subSubItem As UIHierarchyItem
            For Each subSubItem In subitem.UIHierarchyItems
                sb.AppendLine("        " & subSubItem.Name)
            Next
        Next
    Next
    MsgBox(sb.ToString)
 End Sub
using System.Text;
using EnvDTE;
using EnvDTE80;
using EnvDTE90;
using EnvDTE100;public void OnConnection(object application, ext_ConnectMode 
  connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.
    slnExplUIHierarchyExample(_applicationObject);
}

public void slnExplUIHierarchyExample(DTE2 dte)
{
    UIHierarchy UIH = dte.ToolWindows.SolutionExplorer;
    // Requires a reference to System.Text.
    // Set a reference to the first level nodes in Solution Explorer. 
    // Automation collections are one-based.
    UIHierarchyItem UIHItem = UIH.UIHierarchyItems.Item(1);
    StringBuilder sb = new StringBuilder();

    // Iterate through first level nodes.
    foreach ( UIHierarchyItem fid in UIHItem.UIHierarchyItems )
    {
        sb.AppendLine(fid.Name);
        // Iterate through second level nodes (if they exist).
        foreach ( UIHierarchyItem subitem in fid.UIHierarchyItems )
        {
            sb.AppendLine("   "+subitem.Name);
            // Iterate through third level nodes (if they exist).
            foreach ( UIHierarchyItem subSubItem in 
              subitem.UIHierarchyItems )
            {
                sb.AppendLine("        "+subSubItem.Name);
            }
        }
    }
    System.Windows.Forms.MessageBox.Show(sb.ToString());
}

참고 항목

작업

방법: 추가 기능 만들기

연습: 마법사 만들기

개념

VSProject2 개체 소개

자동화 개체 모델 차트

기타 리소스

환경 창 만들기 및 제어

추가 기능 및 마법사 만들기

자동화 및 확장성 참조