By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,275 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,275 IT Pros & Developers. It's quick & easy.

List box, quickly removing many items

P: n/a
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 list box. The problem is that
if there are many items selected (thousands), then removing the items from
the right side list box takes for ever because we are removing them one at a
time, which causes the listbox to re-index everything before we remove the
next one. Adding the items using AddRange works very quickly. Does anyone
have any suggestions for quickly removing items from a listbox?
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
This is what the CheckedListBox is for.
Have you tried to Clear the list and call AddRange minus the items you
intend to remove?

Otherwise, I'm sure there's some unmanaged code for this.

HTH;
Eric Cadwell
http://www.origincontrols.com
Nov 15 '05 #2

P: n/a
Jeremy,
In addition to Eric's comments.

Have you considered putting ListBox.BeginUpdate & ListBox.EndUpdate around
the code that removes the items?

The help only mentions Add with BeginUpdate, however I would expect it to
work with Remove as equally well...

Hope this helps
Jay

"Jeremy Owens-Boggs" <an*******@discussions.microsoft.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
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 list box. The problem is that if there are many items selected (thousands), then removing the items from
the right side list box takes for ever because we are removing them one at a time, which causes the listbox to re-index everything before we remove the
next one. Adding the items using AddRange works very quickly. Does anyone have any suggestions for quickly removing items from a listbox?

Nov 15 '05 #3

P: n/a
Thank you for your input. Using the BeginUpdate and EndUpdate do not speed
up the remove operation, they did remove the anoying 'flicker' when moving
the items. I like the idea of moving to a checked listbox, the big problem
is the sheer number of items in the list box, if it has to reindex each time
an item is removed, it is just going to take to long.

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uJ****************@TK2MSFTNGP09.phx.gbl...
Jeremy,
In addition to Eric's comments.

Have you considered putting ListBox.BeginUpdate & ListBox.EndUpdate around
the code that removes the items?

The help only mentions Add with BeginUpdate, however I would expect it to
work with Remove as equally well...

Hope this helps
Jay

"Jeremy Owens-Boggs" <an*******@discussions.microsoft.com> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl...
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 list box. The problem is

that
if there are many items selected (thousands), then removing the items from the right side list box takes for ever because we are removing them one at a
time, which causes the listbox to re-index everything before we remove

the next one. Adding the items using AddRange works very quickly. Does

anyone
have any suggestions for quickly removing items from a listbox?


Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.