473,385 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

remove from listBox

How to remove a selected item from listBox?

Hrcko
Nov 17 '05 #1
3 2460
Hrcko wrote:
How to remove a selected item from listBox?

[...snip...]

foreach (ListViewItem item in this.myListBox.Items)

{

item.Selected = false;

};
Nov 17 '05 #2
> 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...
Nov 17 '05 #3
Hi,

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

HTH,
Regards,
Angrez

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Supra | last post by:
in vb6 listbox1.remove item 5 how will i do in vb.net? regards
4
by: Bilo | last post by:
I dont know what i am doing false. the code : private void button2_Click(object sender, System.EventArgs e) { foreach (string filename in listBox1.SelectedItems)...
4
by: mostafa atalla | last post by:
How can I remove some selected items from the listBox in the run time ??
1
by: Dan Bass | last post by:
I'm looking to develop a listbox with in-place editing where as each item is selected, it grows to fit in all the text boxes. When the item is deselected, it shrinks back to its original size. The...
4
by: Ron | last post by:
I've got a listbox that holds a list of groups. Users can select a group, hit the remove button and the group should be removed from the listbox. The only problem is that no matter which group you...
1
by: deepak | last post by:
hi , i have 2 listbox and 2 buttons like add and remove, both listbox have multiple selection true so that i can either add or remove multiple selected items. the first listbox is populated with...
3
by: Bill Nguyen | last post by:
I use the following example (from another post) and it seemed to work fine. However, when I add the syntax to remove the selected item from the senderbox, I got error....
7
by: Mike Johnson | last post by:
How do I remove a item that's been selected from a listview? I'm using Visual Basic 2005 express edition. Thanks
11
by: Andrus | last post by:
1. Run code 2. Resize window Observed: Listbox flashes during resize. How to remove this flashing ? Andrus.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.