Reputation:
I have 10 CComboBox in a tab page and I want to load 10k data to each combobox?
It is taking more time for the tab page to get loaded.
In MFC how to implement virtual combobox like virtual list control?
I need to set default selection in the combobox on loading tab.
Can you please someone give me some ideas?
Thanks
Upvotes: 0
Views: 498
Reputation: 15355
There is no such virtual Combobox in the WinApi, but you have serveral optimizations.
Only load the complete data to the box, if needed. So only when you get the CBN_DROPDOWN
event you populate the box with all items. Otherwise you just insert the one selected item.
This method has a drawback that cursor up down in a closed combo doesn't work.
Also you can populate the box only when it receives the focus. Also in this case you just populate the box with the current selected item.
The best result you get is using a owner draw combobox, without using CBS_HASSTRING
. CB_ADDSTRING
receives a pointer to your data. In DrawItem
you use this pointer for drawing.
You still need to add 10k items to each box, but there is no string management and the box is real fast without this memory allocations.
Upvotes: 1