foreach (string imageFile in files)
{
try
{
System.Drawing.Image myImage = Image.FromFile(imageFile);
myImageList.Images.Add(myImage);
myImage.Dispose();
}
catch { }
}
for (int i = 0; i < myImageList.Images.Count; i++) //I have a list view containing images
{
ListViewItem item = new ListViewItem();
item.ImageIndex = i;
imageListView.Items.Add(item);
}
private void imageListView_Clicked(object sender, EventArgs e)
{
string myImage = imageListView.SelectedItems.ToString(); //get the name of image selected
}
现在我想在选择图像时获取图像的名称,类似于上面的 imageListView_Clicked() 函数:
但它不起作用。