We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

_DTE.SelectedItems Property

Gets a collection containing the items currently selected in the environment.

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

SelectedItems SelectedItems { get; }

Property Value

Type: EnvDTE.SelectedItems
A SelectedItems collection.

public void SelectedItemsExample(DTE2 dte)
{
    // Before running this example, open a project and select some 
    // items in Solution Explorer.

    string msg = "";

    foreach (SelectedItem item in dte.SelectedItems)
        msg += item.Name + "\n";

    MessageBox.Show(
        "The following items are selected in Solution Explorer:\n\n" + 
        msg);
}

Show: