Export (0) Print
Expand All

SelectedItem.DTE Property

Gets the top-level extensibility object.

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

DTE DTE { get; }
/** @property */
DTE get_DTE ()

function get DTE () : DTE

Property Value

A DTE object.

In Visual Studio, the DTE object is the root of the automation model, which other object models often call "Application."

public void CodeExample(DTE2 dte)
{  
    try
    {
        // Open project and select one or more items in the
        // solution explorer before running this example.
        SelectedItem selItem;
        string msg = "";
        if (dte.SelectedItems.Count > 0)
        {
            selItem = dte.SelectedItems.Item(1);
            msg = "The first selected item is " + selItem.Name;
            msg += "\nThis SelectedItem corresponds to the following ProjectItem: " + selItem.ProjectItem.Name;
            msg += "\nThis SelectedItem is part of a collection of " + selItem.Collection.Count.ToString() + " items.";
            msg += "\nThis is contained in the following application: " + selItem.DTE.Name;
        }
        MessageBox.Show(msg);
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Community Additions

ADD
Show:
© 2014 Microsoft