我想将图像从列表显示到图片框。我的图像显示在图片框中,但问题是它显示了列表中定义的图片框中图像的大小。谁能告诉我如何放大我的图像尺寸?
这是我的一段代码:
private void listView_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (ListViewItem itm in listView.SelectedItems)
{
int imgIndex = itm.ImageIndex;
if (imgIndex >= 0 && imgIndex < this.documents.Images.Count)
{
// this.documents.Images[imgIndex].Width = 417;
pictureBox.Image = this.documents.Images[imgIndex];
}
}
}
这就是我从数据库中获取图像的方式:
ImageList documents = new ImageList();
if (documents.Images.Count < 1)
{
MessageBox.Show("No Documents Found.");
}
else
{
// pictureBox.Image = documents.Images[1];
this.listView.View = View.LargeIcon;
documents.ImageSize = new Size(256, 256);
listView.LargeImageList = documents;
listView.Items.Clear();
for (int j = 0; j < documents.Images.Count; j++)
{
ListViewItem item = new ListViewItem();
item.ImageIndex = j;
this.listView.Items.Add(item);
}
}