如何在列表视图中显示图像

问题描述:

我在imagelist1中有几个图像。我想在listview1控件中显示图像(或其他人推荐的东西)。一旦图像被选中,它应该显示在一个picturebox1中。我应该能够浏览(下一张/上一张)图片,我也应该能够删除图片。如何在列表视图中显示图像

ImageList1.Images.Add(Image.FromFile(OpenFileDialog1.FileName))不添加文件!

+2

http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.largeimagelist.aspx – 2012-01-16 10:22:11

代码未完成;您还需要在ListView1控件中添加一个项目,并且必须在说明此项目具有新的图像之后。下面一个例子:

Dim newImageKey As String = "<Type here a Key for the image>" 
    ImageList1.Images.Add(newImageKey, Image.FromFile(OpenFileDialog1.FileName)) 
    ListView1.Items.Add("<Your Key Node>", "<Your Text Node>", newImageKey) 
+0

Flaick,我复制你的代码。你能回答我的实际问题吗?我可以将图像从imagelist1显示到listview1吗? – Farook 2012-01-16 11:33:00

+0

对不起,你已经回答了我的Listview问题。让我试试看。 – Farook 2012-01-16 11:40:40

+0

Dim newImageKey As String =“10” LoginForm.ImageList1.Images.Add(newImageKey,Image.FromFile(OpenFileDialog1.FileName)) ListView1.Items.Add(“1”,“Some Image”,newImageKey)是否正确?代码是正确的; – Farook 2012-01-16 11:51:39