SelectedItems::Item Method (Object^)
Visual Studio 2015
Returns a SelectedItem object in the SelectedItems collection.
Assembly: EnvDTE (in EnvDTE.dll)
Parameters
- index
-
Type:
System::Object^
Required. The index or name of the selected item to return.
The value passed to Index is either an integer equating to a SelectedItem object in the SelectedItems collection or a string value that equates to the name of a selected item in the collection.
The Item method throws a ArgumentException exception if the collection cannot find the object that corresponds to the index value.
public void CodeExample(DTE2 dte) { try { // Open project and select one or more items in // 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; } MessageBox.Show(msg); } catch(Exception ex) { MessageBox.Show(ex.Message); } }
Show: