views:

214

answers:

2

Hi, I need to add multiple images to a list view item that is in each row of the list view and each column has different images ?

Regards, Fran

A: 

First thing to ask which version of the control you're using? The more recent one allow such thing. All you need to do is to add the images to its associated ImageList and set the appropriated properties.

Paulo Santos
Hi thanks for your reply .I use the Version 2.0 ListView
A: 

I'm not sure if I'm following the question exactly.

If you are asking how to associate two images to a single ListViewItem in one row of a ListView control I don't believe it is possible. I believe the image for each item acts as a unique key for that entry.

If you are asking how to create two entries in a ListView control with different images that otherwise have the same values you could use something like the following:

ImageList imgList = new ImageList();
listViewControl.SmallImageList = imgList;
imgList.Images.Add("image_one_key", new Icon("filenameOfImageOne"));
imgList.Images.Add("image_two_key", new Icon("filenameOfImageTwo"));
ListViewItem itemOne = new ListViewItem(("Test Object",imgList.Images.IndexOfKey("image_one_key"));
ListViewItem itemTwo = new ListViewItem(("Test Object", imgList.Images.IndexOfKey("image_two_key"));
listViewControl.Items.Add(itemOne);
listViewControl.Items.Add(itemTwo);
Brad
Hi Brad,Thanks for your reply but i need an image to be inserted in sub items of the listview not just the first column of the listview item whic is done as you specified .