Select to view content in your preferred language

Combobox AddItem performance

706
2
11-28-2012 04:03 AM
Dag_MartinRomslo
Emerging Contributor
I am using combobox with dynamic content, i.e. I repopulate the combobox on other user actions.
I have trouble with the performance of AddItem operations. It is extremely CPU expensive. Some of my comboboxes have over 100 elements (bad UX, I know :-)).
Is there a solution to this, other than to limit the number of items?
Sample test code:
ctrl.Clear();
for (var i = 0; i < 500; i++) {
       ctrl.AddItem("desc" + i, "val" + i);
}
Tags (3)
0 Kudos
2 Replies
GarethWalters
Deactivated User
Hi Dag,

If you are finding that process intensive perhaps your device is not appropriate for your needs. I don't know what device you are using.

Are you using AXF data or shp files? Perhaps with AXF you can use SQL statements to update the table which might be quicker.

For example have 1 table with everything in it. Have a duplicate table, but completely empty. Attach this to your combo box. When you make the change call a SQL command to update the empty table attached.

Let me know how you go.

Cheers,

Gareth
0 Kudos
Dag_MartinRomslo
Emerging Contributor
Hi.
The operation is CPU intensive on all devices I have tested on. Approximate benchmarking on my laptop shows that the operation requires 12 000 000 000 CPU cycles.

The method AddItemsFromTable() is much better. If I dynamically create a dbf from code and use this method, the same content requires 300 000 000 CPU cycles.

Since I'm not using AXF, my solution to this is to use the second method described in cases where number of items are large.
0 Kudos