remove from listBox

  • Thread starter Thread starter Hrcko
  • Start date Start date
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...
 
Hi,

Get the selected index from the dropdownlist.selectedIndex property and
use dropdownlist.removeat(index) method.

HTH,
Regards,
Angrez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

remove selected item 1
listbox search 1
sum 4
array list 15
ckecked listbox 4
Access Using DAO.Database VBA code to populate a listbox from another listbox selection 1
checked listbox check all 3
checkedlistBox and listBox 1

Back
Top