看來你正在將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