我在网上搜了这样一段代码,可是还是解决不了问题,
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];
        }
    }
}
出现问题了:达不到上图要的效果。请求各位大哥的帮忙修改,非常感谢了!

解决方案 »

  1.   

     private void Form1_Shown(object sender, EventArgs e)
      {
       //加上下面这行
       this.listView1.View = View.LargeIcon;

      DialogResult dr = this.openFileDialog1.ShowDialog();
      if (dr == DialogResult.OK)
      {
      

  2.   

    谢谢,可还是不行,我上传的图片,在listview中显示的是同一个缩罗图,并且点击第二个以后的图片,还是报错。小弟是出入C#的菜鸟,恳求详细解答。
      

  3.   

    this.listView1.View = View.LargeIcon;
    this.openFileDialog1.Multiselect = true;
    this.listView1.LargeImageList = this.imageList1;这3行加到构造函数末尾
    检查 Form1_Shown 和 listView1_SelectedIndexChanged 两个方法有没关联到相关事件