如何从listview获取图像并分配到picturebox?

时间:2010-07-14 08:39:17

标签: .net c#-2.0

我有一个列表视图,其中我已存储图像,现在我的幻灯片我希望这个图像到图片框。但没有准确的方法从列表视图中获取图像。

任何人都可以对此有所了解吗?

提前感谢。

1 个答案:

答案 0 :(得分:1)

前段时间我遇到过类似的问题。 Microsoft的这篇文章非常有用:http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.image%28VS.80%29.aspx

特别是这部分

   ListViewItem selection = ListView1.GetItemAt(e.X, e.Y);

   // If the user selects an item in the ListView, display
   // the image in the PictureBox.
   if (selection != null)
   {
        PictureBox1.Image = System.Drawing.Image.FromFile(
            selection.SubItems[1].Text);
   }