如图 要的效果:

我想用 lilstview显示缩略图,picturebox显示大图
在网上搜了段这样的代码,可以还是有问题。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private string[] files;
public Form1()
{
InitializeComponent();
}
private void Form1_Shown(object sender, EventArgs e)
{
DialogResult dr = this.openFileDialog1.ShowDialog();
if (dr == DialogResult.OK)
{
this.files = this.openFileDialog1.FileNames;
for(int i=0;i<files.Length;i++)
{
this.imageList1.Images.Add(Image.FromFile(this.files[i]));
this.listView1.Items.Add(this.files[i].Substring(this.files[i].LastIndexOf(@"\")+1), i);
}
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.listView1.SelectedItems.Count > 0)
this.pictureBox1.ImageLocation = this.files[this.listView1.SelectedItems[0].Index];
}
}
}
出现问题了:只能显示一张图片的名称,达不到上图要的效果。请求各位大哥的帮忙,非常感谢了!
------解决方案--------------------------------------------------------
openFileDialog1.Multiselect = true;
------解决方案--------------------------------------------------------
openFileDialog1.Multiselect
list<Image>保存
Image.GetThumbnailImage
------解决方案--------------------------------------------------------
添加一个ImageList,图片添加到ImageList中,设置ListView的ImageList属性为这个ImageList。设置每个对象对应的ImageIndex属性为正确的。设置ListView的View为LargeIcon。剩下的你已经实现了。就可以了。
注意要先设置ImageList的ColorDeapth属性。