Freigeben über


ToolBoxItem2.DTE-Eigenschaft

Ruft das Erweiterbarkeitsobjekt der obersten Ebene ab.

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

Syntax

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

Eigenschaftswert

Typ: EnvDTE.DTE
Ein DTE-Objekt.

Hinweise

In Visual Studio stellt das DTE-Objekt das Stammobjekt des Automatisierungsmodells dar, das in anderen Objektmodellen häufig als "Anwendung" bezeichnet wird.

Beispiele

In diesem Beispiel wird das zweite ToolBoxItem2-Element ausgewählt und dessen Name in einem Meldungsfeld angezeigt.Außerdem wird in dem Beispiel die durch das ToolBoxItem2.DTE-Objekt abgerufene Beschriftung für das aktive Fenster angezeigt.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)
    ToolBoxItemDTEExample(_applicationObject)
End Sub
Sub ToolBoxItemDTEExample(ByVal dte As DTE2)
    Dim tlBox As ToolBox
    Dim tbxTabs As ToolBoxTabs
    Dim tbxTab As ToolBoxTab2
    Dim tbxItem As ToolBoxItem2
    ' Before running this example, open a Windows Application project.
    Try
        ' Create an object reference to the IDE's ToolBox object and
        ' its tabs.
        tlBox = CType(_applicationObject.Windows.Item _
         (Constants.vsWindowKindToolbox).Object, ToolBox)
        tbxTabs = tlBox.ToolBoxTabs
        ' Select the second Toolbox tab.
        tbxTab = CType(tbxTabs.Item(2), ToolBoxTab2)
        tbxTab.Activate()
        MsgBox("Toolbox tab name: " & tbxTab.Name)
        tbxItem = CType(tbxTab.ToolBoxItems.Item(2), ToolBoxItem2)
        MsgBox("Toolbox item name: " & tbxItem.Name)
        MsgBox(tbxItem.Name & "'s active window caption, _
        obtained through the DTE object:" & vbCr  _
        & tbxItem.DTE.ActiveWindow.Caption)
    Catch ex As System.Exception
        MsgBox("ERROR: " & ex.Message)
    End Try
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;
    ToolBoxItemDTEExample(_applicationObject);
}
public void ToolBoxItemDTExample(DTE2 dte)
{
    ToolBox tlBox;
    ToolBoxTabs tbxTabs;
    ToolBoxTab2 tbxTab;
    ToolBoxItem2 tbxItem;
    // Before running this example, open a Windows Application project
    // and select Toolbox from the View menu.
    try
    {
        // Create an object reference to the IDE's ToolBox object
        // and its tabs.
        tlBox = (ToolBox)_applicationObject.Windows.Item
(Constants.vsWindowKindToolbox).Object;
        tbxTabs = tlBox.ToolBoxTabs;
        // Select the second Toolbox tab.
        tbxTab = (ToolBoxTab2)tbxTabs.Item(2);
        tbxTab.Activate();
        MessageBox.Show("Toolbox tab name: " + tbxTab.Name);
        tbxItem = (ToolBoxItem2)tbxTab.ToolBoxItems.Item(2);
        MessageBox.Show("Toolbox item name: " + tbxItem.Name);
        MessageBox.Show(tbxItem.Name + "'s active window caption,
 obtained through the DTE object:" + "\n" 
+ tbxItem.DTE.ActiveWindow.Caption);
    }
    catch (Exception ex)
    {
        MessageBox.Show("ERROR: " + ex.Message);
    }
}

.NET Framework-Sicherheit

Siehe auch

Referenz

ToolBoxItem2 Schnittstelle

DTE-Überladung

EnvDTE80-Namespace