tags:

views:

244

answers:

2

Hello there,

I'm ownerdrawing .Net Windows Forms ListView control and see a very strange bug/behavior when I need to draw an image from the associated LargeImageList.

When the View type is a type where LargeImageList is used (Tile, LargeIcon, etc.), I draw item images from the LargeImageList. At that condition, I see a huge memory increase and when you try to scroll ListView this becomes more obvious as you see a jerky scroll as well. This same thing does not happen when the same code uses SmallImageList which is simply like this :

Image MyImage = this.LargeImageList.Images[MyIndex]; e.Graphics.DrawImage(MyImage,MyLocation);

This is reproducable under XP and 7 according to my tests. Is this a known bug, any workaround?

Regards,

Özden

A: 

How are you managing the invalidated drawing area? As you are saying, looks like you are "overdrawing" the control, I mean, drawing even when it is not necessary.

jonaspp
Starting from .Net 2, ListView provides ownerdraw feature and raises events such as DrawItem, DrawSubItem, etc. These events, I suppose, are raised for each item when they need to be redrawn. I do not override the controls WNDProc to catch the WM_PAINT or any other thing.
Özden Irmak
+2  A: 

Although I still think this is a bug, I found a workaround. If you draw using ImageList.Draw instead of e.Graphics.DrawImage this problem seems to go away.

Özden Irmak