Discussion Locked

Combo Box Load

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a list of items I want to display in the drop down combo box. The list has 2620 items in it. Using the Additem property of the combo box in a loop takes several seconds to load the list.

Does any one know an API or other way to load a large list into a combo box quickly.

Thanks
Mike

10 replies

by peyison

Mike,

I don't think there is an API call for this. Probably your best bet is to get a third party combo box control that can cache the list. It will only read in a small amount to begin with, then read more items as it needs to. Don't know of anynames off hand, but I know I've seen some.

You might also try putting the list in a database and using a data-aware combo linked to the table. I've not tried this, but it might have the same sort of action of getting only the data it needs.

Hope this helps.

by mikedale

Thanks for your comments. The list I am trying to load is in a database. I have been unable to find a third party combo box that improves this. You can use the Sendmessage API to load the combo box. It turns out that the problem is how fast VB can loop through a recordset.
Thanks anyway.

by bob sellman

With so many items you should put the data into a table that the combo box uses as its data source.

To speed the display up, put the table in the front end (application) mdb file, rather than linking to it in the back end (data) mdb file.

Another way to speed up the loading into the combo box is to avoid sorting when you load the data into the combo box from the table. Be sure that the data is physically loaded in the table in the order you want it displayed.

Another advantage with using a table rather than a list is that modifying and adding to the list is very easy.

A last suggestion to speed up loading of data into the combo box is to place the front end (application) mdb file on your users' PCs, rather than running it from the network. This will reduce the need for network traffic to get the list.

by mikedale

Thanks for your comments. I have tried all that you have suggested. With the list in a table and the database on the local PC it still take around 5 seconds to load the list, sorted or not.
Thankls for your help.

by donq

I always base my combo box recordset's on a query linked to a table. As Bob suggested above place the Table on the user PC (if it's values remain constant), or build a one field sorted recordset by query (if the values change often) and past the SQL code from your tested query into the combo boxes "Row Source" property.

by mikedale

The original list I was loading into the combo box was from a query. Placing the database on the local PC speed up the load time but still takes around 5 seconds. This is to long for the user to wait, unfortunately the list gets updatedb daily. The problem seems to be how long VB takes to loop through a Recordset.
Thanks for your comments.

by peyison

You might want to look at the Data Dropdown control that is part of the Data Widgets package from Infragistics (used to be Sheridan). www.infragistics.com. It is one of their "Classic" products.

by peyison

Also, you mention that the speed is based on how fast VB moves through the recordset. It sounds like you're looping through the recordset and using .AddItem to load the data, and not using a bound control. If you try the Data Widgets control (or anyother data aware control), try it in bound mode.

The API call you're talking about does the same thing as .AddItem. I was saying that I don't think there's an API call to load an array into a combo with one call.

good luck

This discussion is closed to new replies.