日期:2014-05-17 浏览次数:21513 次
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];
}
}
}