0

How to add Images to Listview (C# WinForm)?

My problem is that I have to insert 3 images to Listview in column 1,2 and 8 like this image below.

My code:

ListViewItem lvi = new ListViewItem();
//do something to add Image 1
//do something to add Image 2
lvi.SubItems.Add("Sell");
lvi.SubItems.Add("100");
lvi.SubItems.Add("ABC");
lvi.SubItems.Add("10,99");
lvi.SubItems.Add("OK");
//do something to add Image 3

listView1.Items.Add(lvi);

enter image description here

Any recommendation will be highly appreciated.

anhtv13
  • 1,636
  • 4
  • 30
  • 51

1 Answers1

0

You can use ListView with OwnerDraw set to true and handle all the drawing inside the DrawSubItem event. There are many examples. E.g. Extended ListView. This answer can be handy, too.

Community
  • 1
  • 1
Jacob Seleznev
  • 8,013
  • 3
  • 24
  • 34