I have a VB6 application with a search screen. On the search, I have 9 combo boxes. Some of the combo boxes only have a couple items, but some have a couple hundred items. It takes a long time (couple of seconds) to populate the data.
Each combo box is configured the same: Sorted = False, Style = 2 – Dropdown List
3 of the combo boxes have less that 20 items.
1 has 130 items.
4 have approximately 250 items
1 has almost 700 items.
I fill all nine combo boxes with similar code.
While Not RS.EOF
cmbX.List(i) = RS("Description")
cmbX.ItemData(i) = RS("Id")
i = i + 1
RS.MoveNext
Wend
I tried setting Visible = False but it had no effect on performance.
Is there another way to fill the combo box that will perform better than my existing method?
Here is something you can try. According to this post you can shave about 60% off your overhead by using a Windows API function to populate the combo box, instead of the usual AddItem method:
You might be able to shave a little more off by omitting the function call, and just calling the API function directly.