views:

1751

answers:

2

My Listview is setup in the details view with the following column headers:

Image Name || Image Location || Image Size || Image Preview

I would like to know if there is a way to draw an image in the 4th column there. The only way I know, is to set

this.listview1.OwnerDraw = true
this.listView1.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(listView1_DrawColumnHeader);
this.listView1.DrawItem += new System.Windows.Forms.DrawListViewItemEventHandler(listView1_DrawItem);
this.listView1.DrawSubItem += new System.Windows.Forms.DrawListViewSubItemEventHandler(listView1_DrawSubItem);

The problem with this is I have to handle ALL the listview drawing myself... I was wondering if there is a better way to draw in image to a subItem, or if there is a way to only handle the DrawSubItem event?

+1  A: 
Grammarian
A: 

There is some e.Handled = true setting for other controls, but it seems that ListView dont have this option... Hope that someone knows answer to this problem.

I found solution.

In listView1_DrawColumnHeader and listView1_DrawItem event handlers you should put this

e.DrawDefault = true;

It will use default drawing implementation for columns and items, all you have to do is write your own implementation only for subitems.

zidane