How do I determine if multiple items are selected in a ListBox

SelectedIndices is what you want if you have enabled multi-select. You can also check the size of the SelectedItems property.

The documentation for ListBox.SelectedIndex states:

For a standard ListBox, you can use this property to determine the index of the item that is selected in the ListBox. If the SelectionMode property of the ListBox is set to either SelectionMode.MultiSimple or SelectionMode.MultiExtended (which indicates a multiple-selection ListBox) and multiple items are selected in the list, this property can return the index to any selected item.

Try this

if( listBox1.SelectedItems.Count > 1 )
{
    // multiple items are selected
}

Leave a Comment