ListBox.SelectedItems 屬性

定義

取得集合,其中含有 ListBox 中目前選取的項目。

public:
 property System::Windows::Forms::ListBox::SelectedObjectCollection ^ SelectedItems { System::Windows::Forms::ListBox::SelectedObjectCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.ListBox.SelectedObjectCollection SelectedItems { get; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectedItems : System.Windows.Forms.ListBox.SelectedObjectCollection
Public ReadOnly Property SelectedItems As ListBox.SelectedObjectCollection

屬性值

ListBox.SelectedObjectCollection

ListBox.SelectedObjectCollection,含有控制項中目前選取的項目。

屬性

備註

對於多重選取 ListBox 範圍,這個屬性會傳回集合,其中包含 在 中 ListBox 選取的所有專案。 對於單一選取範圍 ListBox ,這個屬性會傳回集合,其中包含中唯一選取專案的單一專案 ListBox 。 如需有關如何操作集合專案的詳細資訊,請參閱 ListBox.SelectedObjectCollection

類別 ListBox 提供數種方式來參考選取的專案。 您可以使用 屬性,而不是使用 SelectedItems 屬性來取得單一選取 ListBox SelectedItem 專案中目前選取的專案。 如果您想要取得目前在 中 ListBox 選取之專案的索引位置,而不是專案本身,請使用 SelectedIndex 屬性。 此外,如果您想要取得多重選取 ListBox 專案中所有選取專案的索引位置,可以使用 SelectedIndices 屬性。

適用於