如何在可滚动面板中查看图像
问题描述:
有什么方法可以在列表视图或图像列表中查看图像吗?我正在使用c#winapp.当用户在文本框中输入查询时,系统运行,然后文本框中的文本将搜索xml文件.当文本匹配时,一个或多个图像将出现在图像列表或图片框中(如果文本包含多个图像或只有一个图像),则最适合的图像.
请帮助我完成这个项目..谢谢:)
is there any way to view images in listview or imagelist? i''m using c# winapp. the system goes when the user inputs a query in the textbox, then the text in the textbox will search the xml file. when the text match, the image or images will appear in imagelist or picturebox (if the text has many images or just one), whatever will fits most.
please help me with this project.. thanks :)
答
尝试一下,希望对您有所帮助:
Try this, hope it will help you:
private void Form1_Load(object sender, EventArgs e)
{
this.listView1.LargeImageList = this.imageList1;
DirectoryInfo di = new DirectoryInfo(@"F:\TEMP\");
this.listView1.View = View.LargeIcon;
foreach (FileInfo fi in di.GetFiles("*.jpg"))
{
this.listView1.Items.Add(new ListViewItem(fi.Name, fi.FullName));
this.imageList1.Images.Add(fi.FullName, Image.FromFile(fi.FullName));
}
}