views:

894

answers:

5

I have an ownerdrawn ListView that "smears" when I scroll. It only affects the last displayed item as it moves into the visible are of the list...

It looks like:

Blah
Blah
Blah

...have all been drawn on top of each other 1 pixel apart. The code in the DrawItem event is of the form

Rectangle rect = new Rectangle(e.Bounds.X + mIconSize.Width, 
   e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawString(episode.ToString(), this.Font, mBlackBrush, rect);

I'm completely stumped. Any ideas gratefully appreciated! Dave

+1  A: 

You can enable double buffering for ListView by deriving from it and setting DoubleBuffered = true. There's a noticeable reduction in flicker, especially in Tile view, once you turn Double Buffering on.

Arnshea
Turns out it was a double buffering problem. I needed to create a class inheriting from ListView and turn double buffering on in the constructor
David Hayes
A: 

also, int the form's own properties, you can enable DoubleBuffer. additionally, there are a couple of commands you can use.

More information can be found by searching DoubleBuffer C# at google (sorry, as a new user I can't post links).

Nefzen
A: 

This is a known bug in the ListView control.

Bo Skjoett
A: 

I have the same issue. Windows 7 only. Double Buffering doesn't help. The listbox is ownerdraw fixed.

So far I do not know of any answer.

Geoffrey Slinker
+1  A: 

In detail view drawing do all of your drawing in DrawSubItem(...). The problem is drawItem is getting called for the first item and DrawSubitem is also for the same item ... with slightly different bounds.

Bryan
That sounds sensible I'll try that!
David Hayes