次の方法で共有


ToolWindows.SolutionExplorer プロパティ

ソリューション エクスプローラーを表す UIHierarchy オブジェクトを取得します。

名前空間:  EnvDTE80
アセンブリ:  EnvDTE80 (EnvDTE80.dll 内)

構文

'宣言
ReadOnly Property SolutionExplorer As UIHierarchy
UIHierarchy SolutionExplorer { get; }
property UIHierarchy^ SolutionExplorer {
    UIHierarchy^ get ();
}
abstract SolutionExplorer : UIHierarchy with get
function get SolutionExplorer () : UIHierarchy

プロパティ値

型 : UIHierarchy
UIHierarchy オブジェクト。

この例では、ソリューション エクスプローラーをアクティブにし、項目を選択し、項目の数を表示した後で閉じます。 この例を実行する前に、Visual Studio 統合開発環境 (IDE) でプロジェクトを開きます。

このアドインの例を実行する方法の詳細については、「方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する」を参照してください。

Imports EnvDTE
Imports EnvDTE80
Public 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)
    SolExplorerManip(_applicationObject)
End Sub
Public Sub SolExplorerManip(ByVal dte As DTE2)
    ' Open a project in Visual Studio, before running this add-in.
    Dim solExplorer As UIHierarchy
    solExplorer = dte.ToolWindows.SolutionExplorer
    MsgBox("Activating Solution Explorer...")
    solExplorer.Parent.Activate()
    MsgBox("Seleting some items in Solution Explorer...")
    solExplorer.SelectDown(vsUISelectionType.vsUISelectionTypeExtend, _
    2)
    MsgBox("The count of items in Solution Explorer is: "  _
    & solExplorer.Parent.Collection.Count.ToString())
    MsgBox("Closing Solution Explorer." & vbCr & _
    "If you made changes you will be prompted to save.")
    solExplorer.Parent.Close(vsSaveChanges.vsSaveChangesPrompt)
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application, 
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    SolExplorerManip(_applicationObject);
}
public void SolExplorerManip(DTE2 dte)
    {
    // Open a project in Visual Studio, before running this add-in.
    UIHierarchy solExplorer;
    solExplorer = _applicationObject.ToolWindows.SolutionExplorer;
    MessageBox.Show("Activating Solution Explorer...");
    solExplorer.Parent.Activate();
    MessageBox.Show("Seleting the first two items in 
Solution Explorer...");
    solExplorer.SelectDown(vsUISelectionType.vsUISelectionTypeExtend,
 2);
    MessageBox.Show("The count of items in Solution Explorer is: "
 + solExplorer.Parent.Collection.Count.ToString());
    MessageBox.Show("Closing Solution Explorer." + "\n" + 
"If you made changes you will be prompted to save.");
    solExplorer.Parent.Close(vsSaveChanges.vsSaveChangesPrompt);
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

ToolWindows インターフェイス

EnvDTE80 名前空間