Disable/Disappear ListView Items

  • Thread starter Thread starter RT
  • Start date Start date
R

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.
 
RT said:
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
 
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 said:
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.
 
Back
Top