Remove selected items from a ListBox

Remove selected items from a ListBox

Suppose you have a ListBox named listBox1. If you want to remove the selected item from it, use the Items.Remove() method, and pass as an argument the SelectedItem property:


However if the ListBox has the SelectionMode set to MultiExtended and you want to remove all the selected items, use the following code:

while(lstKeys.SelectedItems.Count > 0)

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top