How to remove a selected item from listBox?
[...snip...]
O.k., that was how to deselect all items. I should read the postings
properly before responding...
To remove the selected item, use
ListViewItem itemToRemove;
foreach (ListViewItem item in this.myListBox.Items)
{
if (item.Selected == true)
{
itemToRemove = item;
break;
};
};
this.myListBox.Items.Remove(itemToRemove);
If you happen to already know the selected ListViewItem, leave out
everything except the last line. Putting the foreach loop into a method of
it's own might be a good idea...