SelectedItems Interface

Definition

Contains SelectedItem objects, which represent selected projects or project items.

public interface class SelectedItems : System::Collections::IEnumerable
[System.Runtime.InteropServices.Guid("6CAA67CF-43AE-4184-AAAB-0200DDF6B240")]
[System.Runtime.InteropServices.TypeLibType(4160)]
public interface SelectedItems : System.Collections.IEnumerable
[System.Runtime.InteropServices.Guid("6CAA67CF-43AE-4184-AAAB-0200DDF6B240")]
public interface SelectedItems : System.Collections.IEnumerable
[<System.Runtime.InteropServices.Guid("6CAA67CF-43AE-4184-AAAB-0200DDF6B240")>]
[<System.Runtime.InteropServices.TypeLibType(4160)>]
type SelectedItems = interface
    interface IEnumerable
[<System.Runtime.InteropServices.Guid("6CAA67CF-43AE-4184-AAAB-0200DDF6B240")>]
type SelectedItems = interface
    interface IEnumerable
Public Interface SelectedItems
Implements IEnumerable
Attributes
Implements

Examples

Sub SelectedItemsExample()  
   Dim SelItems As SelectedItems  
   Dim SelItemObj As SelectedItem  
   Dim SelContain As SelectionContainer  
   Dim SelItem As SelectedItem  
   Dim NameStr As String  

   SelItems = DTE.SelectedItems  
   ' List the number of items selected.  
   If SelItems.MultiSelect = True Then  
      MsgBox("You have " & SelItems.Count & " items selected in Solution Explorer.")  
   End If  

   ' Set a reference to the first selected item.  
   SelItemObj = SelItems.Item(1)  
   ' List the names of the project or project items under the selected   
   ' item.  
   For Each SelItem In SelItemObj.Collection  
      NameStr = NameStr & SelItem.Name  
      If TypeOf SelItem.Project Is Project Then  
         NameStr = NameStr & " Project-" & SelItem.Project.Name & vbCrLf  
      Else  
         If TypeOf SelItem.ProjectItem Is ProjectItem Then  
             NameStr = NameStr & SelItem.ProjectItem.FileNames(1) & vbCrLf  
         End If  
      End If  
   Next  
   MsgBox("You selected: " & NameStr)  
End Sub  

Remarks

There is always a SelectedItems collection, even when there are no project items. For example, if Solution Explorer has focus and a project node is selected, then there is one SelectedItem object. The selected item's Project property refers to the selected project, and its ProjectItem property is Null.

Properties

Count

Gets a value indicating the number of objects in the SelectedItems collection.

DTE

Gets the top-level extensibility object.

MultiSelect

Gets whether or not the current selection includes multiple items.

Parent

Gets the immediate parent object of a SelectedItems collection.

SelectionContainer

Gets a SelectionContainer object that represents the designer hosting the selected item(s).

Methods

GetEnumerator()

Gets an enumeration for items in a collection.

Item(Object)

Returns a SelectedItem object in the SelectedItems collection.

Applies to