|
-
August 11th, 1999, 08:40 AM
#1
How to delete multiple selection items from a listbox?
On a form, I have two listbox's. One has items in it, the other is empty. I want to be able to transfer items from one listbox to the other. That part I can do. My problem, is that I want to delete the item, that is being transferd, from it's original listbox. For a single selection, it poses no problem, but if you have a multiple selection enable, it is more complex. I cant use the index after I use the removeitem once, since all the indexes are changed. Example: I have five items (index 0 through 4). I select item 1 & 3. Once I transfer these items to the other listbox, I now want to delete them. If I use the removeitem method once for the item index 1, the other item previously selected (index 3) now becomes index 2! So how can I keep track of all this as I delete items? Is using a while(there are still selected items) conditional loop part of the solution?
-
August 11th, 1999, 08:45 AM
#2
Re: How to delete multiple selection items from a listbox?
use a loop like this
for i = list1.listcount-1 to 0 step -1
if list1.selected(i) then
list1.removeitem i
end if
next i
i.e. you loop through the items starting from the end of the list.
-
August 11th, 1999, 03:19 PM
#3
Re: How to delete multiple selection items from a listbox?
loop backwards through the list you are deleting from. This way, your indicies will not change.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|