Here is what i am using, but i get an error:
private void listView1_DoubleClick(object sender, EventArgs e)
{
foreach (ListViewItem itm in listView1.SelectedItems)
{
pictureBox1.Image = System.Drawing.Image.FromFile(itm.SubItems[1].Text);
}
}
i get: InvalidArgument=Value of '1' is not valid for 'index'.
Parameter name: index
How do i fix this problem?
this is how i fill the listview with the images in the image list (which are added in the properties items collection)
for (int j = 0; j < this.imageList1.Images.Count; j++)
{
ListViewItem item = new ListViewItem();
item.ImageIndex = j;
this.listView1.Items.Add(item);
}
You listViewItems have only 1 subitem which appear to be the empty string (which is not a valid path).
An ImageList doesn’t keep the path informations of the images. Instead, it created a copy which is embedded in the executable.
Try this code instead: