ListBox.SelectedItems 属性

定义

获取包含 ListBox 中当前选定项的集合。Gets a collection containing the currently selected items in the 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; }
member this.SelectedItems : System.Windows.Forms.ListBox.SelectedObjectCollection
Public ReadOnly Property SelectedItems As ListBox.SelectedObjectCollection

属性值

ListBox.SelectedObjectCollection,包含控件中的当前选定项。A ListBox.SelectedObjectCollection containing the currently selected items in the control.

属性

注解

对于多重选择 ListBox,此属性将返回一个集合,其中包含在 ListBox中选择的所有项。For a multiple-selection ListBox, this property returns a collection containing all items that are selected in the ListBox. 对于单项选择 ListBox,此属性返回一个集合,其中包含单个元素,该元素包含 ListBox中唯一选定的项。For a single-selection ListBox, this property returns a collection containing a single element containing the only selected item in the ListBox. 有关如何操作集合项的详细信息,请参阅 ListBox.SelectedObjectCollectionFor more information about how to manipulate the items of the collection, see ListBox.SelectedObjectCollection.

ListBox 类提供了许多用于引用所选项目的方法。The ListBox class provides a number of ways to reference selected items. 您可以使用 SelectedItem 属性,而不是使用 SelectedItems 属性获取单选 ListBox中的当前选定项。Instead of using the SelectedItems property to obtain the currently selected item in a single-selection ListBox, you can use the SelectedItem property. 如果要获取 ListBox中当前选定项的索引位置,而不是项本身,则使用 SelectedIndex 属性。If you want to obtain the index position of an item that is currently selected in the ListBox, instead of the item itself, use the SelectedIndex property. 此外,如果想要获取多选 ListBox中所有选定项的索引位置,则可以使用 "SelectedIndices" 属性。In addition, you can use the SelectedIndices property if you want to obtain the index positions of all selected items in a multiple-selection ListBox.

适用于