This documentation is archived and is not being maintained.

ListBox.SelectedItems Property

Gets a collection containing the currently selected items in the ListBox.

[Visual Basic]
Public ReadOnly Property SelectedItems As _
   ListBox.SelectedObjectCollection
[C#]
public ListBox.SelectedObjectCollection SelectedItems {get;}
[C++]
public: __property ListBox.SelectedObjectCollection*
   get_SelectedItems();
[JScript]
public function get SelectedItems() :
   ListBox.SelectedObjectCollection;

Property Value

A ListBox.SelectedObjectCollection containing the currently selected items in the control.

Remarks

For a multiple-selection ListBox, this property returns a collection containing all items that are selected in the ListBox. For a single-selection ListBox, this property returns a collection containing a single element containing the only selected item in the ListBox. For more information on how to manipulate the items of the collection, see ListBox.SelectedObjectCollection.

The ListBox class provides a number of ways to reference selected items. Instead of using the SelectedItems property to obtain the currently selected item in a single-selection ListBox, you can use the SelectedItem property. 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. 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.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

ListBox Class | ListBox Members | System.Windows.Forms Namespace

Show: