Click to See Complete Forum and Search --> : Speed of adding or deleteing items in a listctrl


June 1st, 1999, 07:13 AM
When I added a large number of items(for example, 100000) into a listctrl, it
took more than 3 minute. And when I deleted all the items in this listctrl by
using DeleteAllItems(), it took almost 15 minutes. I already called SetRedraw(
FALSE) before doing these. My PC is PII 450 with 128M memory and the system is
Win98. Does anybody know how to resolve this problem?

Stu
June 3rd, 1999, 03:38 AM
Hi,

One way of doing improving the speed if you know roughly how many items you are inserting is to use CListCtrl::SetItemCount().

This tells the control to allocate memory for the items before you begin inserting them - preventing re-allocation of memory everytime you add another one.

This should improve the speed significantly with the number of items (100,000) you suggest.

Performance will also be impeeded if you've set the CListCtrl to sort the items.

Stuart