Quote Originally Posted by Erwin69 View Post
While I’m finetuning the implementation of the VBCCR components in my application, I discovered a significant performance issue in one area.

I’m using the following steps to show the user a combo with only unique values:

1. All items are added to a sorted listview
2. Then go through the listview from the top, removing double items
3. Last, the remaining items are added to the dropdown

Using a 1000 records dataset, these were the results:

- Using a sorted Microsoft Common Controls listview, the process takes 25 milliseconds.
- Using a sorted VBCCR listview, the process takes 21030 milliseconds.
- Using a non-sorted VBCCR listview, filling it, setting sorting to true, and then do the rest of the process, takes 138 milliseconds.

The first and third approach broken down:

Microsoft ListView
Fill Listview 8 ms
Remove Doubles 14 ms
Fill Combo 3 ms

VBCCR ListView
Fill Listview 28 ms
Switch to sorted 65 ms
Remove Doubles 40 ms
Fill Combo 5 ms

The ListView basically has all properties set to False, except for Enabled, as it's only used behind the scenes, and therefore doesn't need to be displayed, refreshed, etc.

Note: no further action is expected from my side as I can live with the 138 ms, but I thought to share this to show that different approaches can make a massive difference.
Well. The MS ListView will sort kind of "PostMessage" style so you cannot compare it directly.
I think that the VBCCR ListView will sort "directly" is rather a feature than a bug.
You do it correctly that you disable the sort while populating.
I found some spots where maybe a few milliseconds can be saved (e.g. store AddressOf in a variable etc.) When sorting after each insert. However, that fact is neglibile when sorting only once when insertions are finished.

But you can improve by eliminating the duplicates already in the recordset. Also the sorting could be outsourced to the recordset. And ultimate performance would be to make the ListView virtual and fetch the visible viewport data from the recordset only when needed.