次の方法で共有


SelectedItems インターフェイス

選択したプロジェクトまたはプロジェクト項目を表す SelectedItem オブジェクトが含まれます。

名前空間:  EnvDTE
アセンブリ:  EnvDTE (EnvDTE.dll 内)

構文

'宣言
<GuidAttribute("6CAA67CF-43AE-4184-AAAB-0200DDF6B240")> _
Public Interface SelectedItems _
    Inherits IEnumerable
[GuidAttribute("6CAA67CF-43AE-4184-AAAB-0200DDF6B240")]
public interface SelectedItems : IEnumerable
[GuidAttribute(L"6CAA67CF-43AE-4184-AAAB-0200DDF6B240")]
public interface class SelectedItems : IEnumerable
[<GuidAttribute("6CAA67CF-43AE-4184-AAAB-0200DDF6B240")>]
type SelectedItems =  
    interface 
        interface IEnumerable 
    end
public interface SelectedItems extends IEnumerable

SelectedItems 型で公開されるメンバーは以下のとおりです。

プロパティ

  名前 説明
パブリック プロパティ Count SelectedItems コレクション内のオブジェクトの数を示す値を取得します。
パブリック プロパティ DTE トップレベルの機能拡張オブジェクトを取得します。
パブリック プロパティ MultiSelect 現在の選択項目に複数の項目が含まれているかどうかを示す値を取得します。
パブリック プロパティ Parent SelectedItems コレクションの直接の親オブジェクトを取得します。
パブリック プロパティ SelectionContainer 選択した項目 (複数可) をホストするデザイナーを表す SelectionContainer オブジェクトを取得します。

このページのトップへ

メソッド

  名前 説明
パブリック メソッド GetEnumerator コレクション内の項目の列挙子を取得します。
パブリック メソッド Item SelectedItems コレクション内の SelectedItem オブジェクトを返します。

このページのトップへ

解説

プロジェクト項目がない場合でも、SelectedItems コレクションは常に存在します。 たとえば、ソリューション エクスプローラー にフォーカスがあり、プロジェクト ノードが選択されている場合、SelectedItem オブジェクトが 1 つ存在します。 選択した項目の Project プロパティは、選択したプロジェクトを参照します。ProjectItem プロパティは Null です。

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

参照

関連項目

EnvDTE 名前空間