-
July 18th, 2002, 10:17 AM
#1
multiple deletion for listbox
Hi,
I have two listboxes A and B, need to get data from A to B. Now, I can multiselect from A, but can't multi delete from B.
I don't need to move B back to A, just need to delete data when user choose more than one in B.
Any suggestion?
Thanks.
Brad
-
July 18th, 2002, 10:27 AM
#2
i think the reason would be is because when you delete something from a list it has to make the necessary changes to the list, aka delete then move the rest of the items after it up a level. So if it were allowed to multidelete it would have to just do a loop of it's own to make those deletions...so it wuld be best for you to just run a loop
for intI = o to ListA.Listcount -1
if listA.List(intI) = ListA.Selected then
for intJ = 0 to ListB.listcount -1
if listB.List(intJ) = ListA.List(intI) then listB.Remove(intJ)
next intJ
end if
next intI
something like that should work...but maybe someone has a better example or idea
hope this helps
- nc
"In a world without walls and barriers, what need is there for windows and gates!" - a mac ad
"What was the best thing before sliced bread and when did sliced bread go out of existence?" - me
"Software is like sex, it's better when it's free." - Linus Torvalds <- gotten from Andreas Masur
Live Penguine! - Tux the linux mascot
Vivez le penguine!, ¡Viva en penguine!, Lang lebe der Pinguin!, Viva no penguine!, Viva sul penguine!
-
July 18th, 2002, 10:42 AM
#3
You mean you are multi selecting some items in ListBoxB and want to delete them right?
Code:
Dim intSelNum as Integer
Dim I as Integer
Dim intRemNum as Integer
Dim intLstCount as Integer
intSelNum = ListB.SelCount
intRemNum = 0
intLstCount = ListB.ListCount - 1
For I = 0 To intLstCount
If ListB.Selected(I) = True Then
ListB.RemoveItem(I)
intRemNum = intRemNum + 1
If intRemNum = intSelNum Then Exit For 'This keeps it from having errors because your taking one away from the list each time.
End If
Next
That will remove all selected items from a list.
-
July 18th, 2002, 10:58 AM
#4
Originally posted by StevenHickerson
'This keeps it from having errors because your taking one
this is what i was talking about. You need to go one at a time...
sorry if the code is crappy...but i just put it together off the top of my head...
- nc
"In a world without walls and barriers, what need is there for windows and gates!" - a mac ad
"What was the best thing before sliced bread and when did sliced bread go out of existence?" - me
"Software is like sex, it's better when it's free." - Linus Torvalds <- gotten from Andreas Masur
Live Penguine! - Tux the linux mascot
Vivez le penguine!, ¡Viva en penguine!, Lang lebe der Pinguin!, Viva no penguine!, Viva sul penguine!
-
July 18th, 2002, 11:36 AM
#5
'The following code should delete all selected items from ListB
Code:
Private Sub Command1_Click()
Dim ind As Integer
ind = 0
Do While ListB.SelCount > 0
If ListB.Selected(ind) Then
ListB.RemoveItem (ind)
ind = ind - 1
End If
ind = ind + 1
Loop
End Sub
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
|