Freigeben über


ToolWindows.SolutionExplorer-Eigenschaft

Ruft ein UIHierarchy-Objekt ab, das den Projektmappen-Explorer darstellt.

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

Syntax

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

Eigenschaftswert

Typ: UIHierarchy
Ein UIHierarchy-Objekt.

Beispiele

In diesem Beispiel wird der Projektmappen-Explorer aktiviert, es werden darin enthaltene Elemente ausgewählt, diese werden gezählt, die ermittelte Anzahl wird angezeigt, und anschließend wird der Projektmappen-Explorer wieder geschlossen. Öffnen Sie vor dem Ausführen des Beispiels in der integrierten Entwicklungsumgebung (IDE) von Visual Studio ein Projekt.

Weitere Informationen zum Ausführen dieses Beispiels als Add-In finden Sie unter Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell.

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-Sicherheit

Siehe auch

Referenz

ToolWindows Schnittstelle

EnvDTE80-Namespace