PC Review


Reply
Thread Tools Rate Thread

Clearing a listview

 
 
Kevin White
Guest
Posts: n/a
 
      22nd Dec 2008
What is the fastest way to clear the contents of a ListView?
listView1->Clear() takes far too long.

Cheers,
K


 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      22nd Dec 2008
Kevin White wrote:
> 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

 
Reply With Quote
 
David Lowndes
Guest
Posts: n/a
 
      22nd Dec 2008
>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
 
Reply With Quote
 
Jack Jackson
Guest
Posts: n/a
 
      23rd Dec 2008
On Mon, 22 Dec 2008 19:24:30 -0000, "Kevin White" <(E-Mail Removed)> wrote:

>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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clearing a listview Kevin White Microsoft VC .NET 3 23rd Dec 2008 01:31 AM
ListView.ItemCheck event fires on ListView.Items.Insert =?Utf-8?B?RGV2ZWxvcGVy?= Microsoft Dot NET Framework Forms 0 14th Sep 2004 03:21 AM
Listview Item.Selected not populating Listview.SelectedItems collection Chris Adams Microsoft Dot NET Framework Forms 0 23rd Apr 2004 01:30 AM
RE: ListView - images disappear after coming back from another form with a ListView Armin Sadeghi [MSFT] Microsoft Dot NET Compact Framework 0 5th Sep 2003 11:41 PM
Error clearing LISTVIEW items garfitz Microsoft Dot NET Compact Framework 1 22nd Jul 2003 08:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:07 PM.