A trick to 'minimize' for ListView?

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

R

Minimizing an app that uses a ListView in a custom control causes all
entries in the ListView to disappear, never to return. What would
affect this?
 
I've never seen this; can you provide example code to reproduce?

Marc

I guess I may have to trim down that section of code to see where it
breaks. Tedious though. So this is not something that's known? I
thought I had seen mention of something like this before.
 
I guess I may have to trim down that section of code to see where it
breaks.

Yes, that would be a good idea.
Tedious though.

Sometimes debugging is tedious, yes. Still, the very first thing to do
when using a third-party library (even .NET) is to make sure there's
nothing wrong with your own end of things, and one of the best ways to do
that is to simplify your scenario to the most basic elements.

At the very least, you will usually wind up figuring out what exactly
causes the third-party library to break (they do occasionally have bugs,
but usually not in the most obvious, well-used places), which can lead to
a good work-around. And frequently you'll discover that there's something
you've done specifically to cause the third-party library to "break",
revealing that the only thing that's broken is how the third-party library
is used by your own code. :)
So this is not something that's known? I
thought I had seen mention of something like this before.

Never heard of it. I would expect that the general case -- put a ListView
on a minimizable form, populate it, minimize it -- would obviously not be
broken, so the real question is what else are you doing that in
combination with those steps causes the ListView to wind up empty.

If and when you figure that out, please post back here, whether it's a bug
in your code or not. Even if it's a bug in your own code, it may well be
something that someone else might do accidently as well. Having the
solution here will help those people in the future. It's very unusual to
write a bug into code that no one else ever has, and never will, write
into their own code. :)

Pete
 
Quick thought: did you perhaps call BeginUpdate without calling
EndUpdate? This could conceivably have this effect... As a general
rule, you should use try/finally with such operations, i.e.

someControl.BeginUpdate(); // or SuspendLayout()
try {
// your code
} finally {
someControl.EndUpdate(); // or ResumeLayout()
}

Marc
 
Minimizing an app that uses a ListView in a custom control causes all
entries in the ListView to disappear, never to return. What would
affect this?

While playing around with an OwnerDrawn ListView I came across a
problem that seems somewhat similar:
I wanted to create a ListView that used gradient colors in the headers
as well as in the background of the entire ListView, so I handled
OnDrawColumnHeader and OnPaintBackground to do my painting, while Item
and Subitem painting were left to the default behavior.
While the gradient effect worked as expected, I couldn't see any of
the items I added to the ListView, it appears that the
OnPaintBackground method was called after the other paint-methods,
causing me to draw over the previously drawn items.
Since it was just for testing purposes anyways I never got around to
looking into the problem (it is very much possible that I simply made
a mistake, though I seem to remember others reporting similar issues
on Google), but maybe it is relevant to yours.

hth,
Kevin Wienhold
 
Back
Top