469,140 Members | 1,158 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,140 developers. It's quick & easy.

Disable/Disappear ListView Items

RT
Is there any way to make Listview items invisible or otherwise keep
them from displaying? Seems like temporarily removing, then restoring
later would be a severe runtime hit.
Aug 26 '07 #1
3 7374
RT wrote:
Is there any way to make Listview items invisible or otherwise keep
them from displaying? Seems like temporarily removing, then restoring
later would be a severe runtime hit.
Why does it seem like it would be a severe runtime hit?

Have you tried it? Is it in fact a severe runtime hit?

Don't waste time optimizing prematurely. It's simple enough to try just
removing things you don't want shown in the ListView, so try that first.
If it works, great. If not, _then_ you can worry about how to make it
faster.

For what it's worth, I suspect that removing/adding items is much _more_
performant than hiding. When you remove something, it is simply not in
the ListView. If you hide it, then every time the ListView draws, it
needs to know not to draw it, which is extra effort. Since the drawing
happens much more often than the removing/adding, it's better to
remove/add items than keep checking to see whether they need to be drawn
(and of course, doing all the layout, etc. that results from changes in
the shown/hidden state).

Of course, all this is probably moot...I don't think that there is in
fact a way to leave something in the ListView items collection and yet
hide it. But even if there were, I don't think performance would be a
reason to take advantage of that.

Pete
Aug 27 '07 #2
RT
On Sun, 26 Aug 2007 17:00:23 -0700, Peter Duniho
<Np*********@NnOwSlPiAnMk.comwrote:
>RT wrote:
>Is there any way to make Listview items invisible or otherwise keep
them from displaying? Seems like temporarily removing, then restoring
later would be a severe runtime hit.

Why does it seem like it would be a severe runtime hit?

Have you tried it? Is it in fact a severe runtime hit?
The ListView lists info on files, so there could be thousands of items
at times. The goal is to set up 'filters' so that subsets can be
displayed.

Re runtime: I've tried some worst-case scenarios, and just adding the
items takes a while.

Also tried using swapping in a different ListView control using some
of the items pulled from the original ListView. Seems that you can't
use a ListViewItem more than once (damn) so I had to do bitwise
clones. Also time-consuming.
>For what it's worth, I suspect that removing/adding items is much _more_
performant than hiding. When you remove something, it is simply not in
the ListView. If you hide it, then every time the ListView draws, it
needs to know not to draw it, which is extra effort.
That's a good point. I thought that if the mechanism was there, that
maybe there would be some internal caching in place.
>Of course, all this is probably moot...I don't think that there is in
fact a way to leave something in the ListView items collection and yet
hide it.
Nothing like a dead end to guide coding strategy, eh? <g>
But even if there were, I don't think performance would be a
reason to take advantage of that.

Pete
Unfortunately, it will perform poorly as it is too.
Aug 27 '07 #3
How many items you add and how? Over 100K?
Could you post the code which is slow?
"RT" <rt@spamfree.xxxwrote in message
news:dc********************************@4ax.com...
On Sun, 26 Aug 2007 17:00:23 -0700, Peter Duniho
<Np*********@NnOwSlPiAnMk.comwrote:
>>RT wrote:
>>Is there any way to make Listview items invisible or otherwise keep
them from displaying? Seems like temporarily removing, then restoring
later would be a severe runtime hit.

Why does it seem like it would be a severe runtime hit?

Have you tried it? Is it in fact a severe runtime hit?

The ListView lists info on files, so there could be thousands of items
at times. The goal is to set up 'filters' so that subsets can be
displayed.

Re runtime: I've tried some worst-case scenarios, and just adding the
items takes a while.

Also tried using swapping in a different ListView control using some
of the items pulled from the original ListView. Seems that you can't
use a ListViewItem more than once (damn) so I had to do bitwise
clones. Also time-consuming.
>>For what it's worth, I suspect that removing/adding items is much _more_
performant than hiding. When you remove something, it is simply not in
the ListView. If you hide it, then every time the ListView draws, it
needs to know not to draw it, which is extra effort.

That's a good point. I thought that if the mechanism was there, that
maybe there would be some internal caching in place.
>>Of course, all this is probably moot...I don't think that there is in
fact a way to leave something in the ListView items collection and yet
hide it.

Nothing like a dead end to guide coding strategy, eh? <g>
>But even if there were, I don't think performance would be a
reason to take advantage of that.

Pete

Unfortunately, it will perform poorly as it is too.

Aug 27 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Dave Y | last post: by
6 posts views Thread by Nick | last post: by
12 posts views Thread by J L | last post: by
6 posts views Thread by Brandon McCombs | last post: by
1 post views Thread by Bob | last post: by
1 post views Thread by =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.