Clearing a listview

  • Thread starter Thread starter Kevin White
  • Start date Start date
K

Kevin White

What is the fastest way to clear the contents of a ListView?
listView1->Clear() takes far too long.

Cheers,
K
 
Kevin said:
What is the fastest way to clear the contents of a ListView?
listView1->Clear() takes far too long.

Clear the rows only? listview1.Items.Clear (or -> instead of .)
Takes only 1.5s even with 100 columns and 10,000 rows.
Didn't test with more data because only filling takes 25s. I think much
more a user should not have to handle.

Usually, when adding a larger number of items, I'd suggest to call
listview1.beginupdate before and listview1.endupdate afterwards. However,
this doesn't make any difference when calling Clear. 1.5s with or without
begin/endupdate.


Armin
 
What is the fastest way to clear the contents of a ListView?
listView1->Clear() takes far too long.

Kevin,

Have you had a look at the remarks section of the LVN_DELETEALLITEMS
message? Are you perhaps getting a LVN_DELETEITEM notification message
for each item?

Dave
 
What is the fastest way to clear the contents of a ListView?
listView1->Clear() takes far too long.

Cheers,
K

Do you have an event handler that gets called when items are removed
or when the selection changes? If so, it probably gets called for
each row that is removed, and if it does a significant amount of
processing that might account for it.
 
Back
Top