c#实现winform下显示批量缩略图形式的图片
前两天刚给别人做了一个类似的
用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];
}
}
}