SelectedItems.Item Method
Returns a SelectedItem object in the SelectedItems collection.
Namespace: EnvDTE
Assembly: EnvDTE (in EnvDTE.dll)
Syntax
'Declaration
Function Item ( _
index As Object _
) As SelectedItem
SelectedItem Item(
Object index
)
SelectedItem^ Item(
[InAttribute] Object^ index
)
abstract Item :
index:Object -> SelectedItem
function Item(
index : Object
) : SelectedItem
Parameters
index
Type: System.ObjectRequired. The index or name of the selected item to return.
Return Value
Type: EnvDTE.SelectedItem
A SelectedItem object.
Remarks
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.
Examples
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);
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Other Resources
How to: Compile and Run the Automation Object Model Code Examples