473,513 Members | 13,099 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Removing Items from a Listbox with Multi-Select enabled

I'm trying to remove a number of items selected in a mulitselect list
box.
the code
For Each varSel In lstAvailableFiles.ItemsSelected
lstAvailableFiles.RemoveItem (varSel)
Next varSel
This will remove the first item select the first time through the loop
but
after one item is removed the all items are deselected so you can't
tell
what others need to be removed ..i.e. the
lstAvailableFiles.ItemsSelected.count falls to 0 after one item is
removed
regardless how many items were originally selected.
Is there a work around ?

Nov 13 '05 #1
1 5308

Try it like this:

For i = lstAvailableFiles.ItemsSelected.Count - 1 to 0 Step -1
lstAvailableFiles.Selected( _
lstAvailableFiles.ItemsSelected(i)) = False
Next i
On 22 Sep 2005 13:19:31 -0700, "microb0x" <wo*******@gmail.com> wrote:
I'm trying to remove a number of items selected in a mulitselect list
box.
the code
For Each varSel In lstAvailableFiles.ItemsSelected
lstAvailableFiles.RemoveItem (varSel)
Next varSel
This will remove the first item select the first time through the loop
but after one item is removed the all items are deselected so you can't
tell what others need to be removed ..i.e. the
lstAvailableFiles.ItemsSelected.count falls to 0 after one item is
removed regardless how many items were originally selected.
Is there a work around ?

--
Drive C: Error. (A)bort (R)etry (S)mack The Darned Thing

Nov 13 '05 #2

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

Similar topics

3
3106
by: Jeremy Owens-Boggs | last post by:
We are trying to implement a dual list box selection where you have two list boxes, You highlight items in the right side list box, click a button and this moves those items over to the left hand...
3
4776
by: Joey | last post by:
Hi, I'm trying to add a default item to my listbox but when I do it tells me that it's not defined, could someone tell me the syntax I need to use to get the listbox control to display a default...
11
4328
by: Robin Tucker | last post by:
SelectedItems and SelectedIndices appear to be read-only, so I cannot remove a selected item. I need to do this to synchronise the selection in my list with the selection in other views (ie....
3
2825
by: Thunder$truck | last post by:
I'm sure this is easy but I can't figure it out. I use a ListBox for my application log and each time the app performs a task an entry is added into the ListBox. When the list box becomes...
14
18636
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe...
1
8299
by: Refugnic | last post by:
I tried to fill a ListBox with a DataSource pointing to an ArrayList. It all works fine...up to one point. The ArrayList is dynamic, which means the contents of it change, during the course of...
1
3650
by: divya | last post by:
Hello, I used the below code to move selected items between two listboxes Left and Right:- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %> ...
2
37770
by: questionit | last post by:
Hi How to delete/ remove all items in a "Value List" ListBox with a button click? I have tried this: For i = 0 To Me.List1.ListCount - 1 Me.List1.RemoveItem (i)
5
2452
by: BlackBox | last post by:
I have a Listbox1 in the main form and I can add listbox1 items in the parent form. But when I close the parent form Listbox1 in the main form does not get refresh. I need to re-open the app. ...
4
2469
by: Andrus | last post by:
I created form which uses double buffering for everything. If form is resized, listbox content is flashing. In MONO ListBox is resized smoothly. How to fix code so that it does not flash in .NET...
0
7254
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
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7432
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...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.