#974 – Properties for Retrieving Selected Items in a ListBox

You can use the following properties to find out which items in a ListBox are selected:

  • If a single item is selected:
    • SelectedIndex is the 0-based index of the selected item
    • SelectedItem refers to the selected item
    • SelectedItems is a list containing the single selected item
  • If multiple items are selected:
    • SelectedIndex is the 0-based index of the first item that the user selected
    • SelectedItem refers to the first item that the user selected
    • SelectedItems is a list containing all selected items
  • If no items in the ListBox are selected:
    • SelectedIndex is -1
    • SelectedItem is null
    • SelectedItems is null

974-002

974-003

974-001