看来你正在将Image locations
存储在同一个DataTable中。如果您在处理foreach循环时将这些图像位置存储在ImageList
中,这将是可以理解的。下面是示例代码:
lvPtMedicalRecord.LargeImageList = myImageList; //Attaching ImageList to the ListView
int imageIndex = 0;
foreach (DataRow rows in dtPath.Rows)
{
//Store the paths of the images in the same DataTable (I can think of this only)
myImageList.Images.Add(Image.FromFile(row[0].ToString());
ListViewItem lvi = new ListViewItem();
lvi.ImageIndex = imageIndex; //Index of the Image present in the `ImageList`
imageIndex++;
lvPtMedicalRecord.Items.Add(lvi);
}
更新:
为了使图像大:
myImageList.ImageSize = new System.Drawing.Size(112, 112); // width, height
我使用列表视图。 – Trax
看看这个:这是[msdn论坛帖子](http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/876b6517-7306-44b0-88df-caebf3b1c10f),它提供了帮助你可能需要。 :) – bonCodigo
@Mr_Green如何让listview中的图像显得更大?我尝试更改'lvPtMedicalRecord.LargeImageList = myImageList;'但图像仍然很小。 – Trax