控件名称:imagelist1、 listView1、pictureBox1我将生成的若干个图片(图片尺寸:1600 x 1200)存储到imagelist1中,然后在让listView1读取并显示,当点击listView1中的某张图片时,让它按原尺寸显示到pictureBox1中。
现在的问题:当我点击listView1中的图片时,在pictureBox中显示的256 x 256的图片,而不是原尺寸(1600 x 1200).求助各位高手。
现在的问题:当我点击listView1中的图片时,在pictureBox中显示的256 x 256的图片,而不是原尺寸(1600 x 1200).求助各位高手。
this.imageList1.Images.Add(img.GetThumbnailImage(256, 256, null, IntPtr.Zero)); this.listView1.Clear();
this.listView1.LargeImageList= this.imageList1;
for (int i = 0; i <this.imageList1.Images.Count; i++)
{
ListViewItem lvi = new ListViewItem();
lvi.ImageIndex = i;
listView1.Items.Add(lvi);
} 点击listView1显示在pictureBox1中的关键代码: for (int i = 0; i < this.listView1.SelectedItems.Count; i++)
{
this.pictureBox1.Image = this.listView1.LargeImageList.Images[this.listView1.SelectedIndices[i]];
}
this.pictureBox1.Show();
this.imageList1.Images.Add(img.GetThumbnailImage(256, 256, null, IntPtr.Zero)); this.listView1.Clear();
this.listView1.LargeImageList= this.imageList1;
for (int i = 0; i <this.imageList1.Images.Count; i++)
{
ListViewItem lvi = new ListViewItem();
lvi.ImageIndex = i;
listView1.Items.Add(lvi);
} 点击listView1显示在pictureBox1中的关键代码: for (int i = 0; i < this.listView1.SelectedItems.Count; i++)
{
this.pictureBox1.Image = this.listView1.LargeImageList.Images[this.listView1.SelectedIndices[i]];
}
this.pictureBox1.Show();
这个在listView1显示pictureBox根据listView1点击的索引去image[]里面取大图显示
Image[] Imgs=new Image[图片数量int];
你把大图片都保存在这个里面
Image[0]代表第一张大图
Image[1]代表第二张
可直接用。就是变量
for (int i = 0; i < this.listView1.SelectedItems.Count; i++)
{
this.pictureBox1.Image = Imgs[i];
}
后一张~
{
this.pictureBox1.Image = Imgs[i];
}
这个肯定是错的
for (int i = 0; i < this.listView1.SelectedItems.Count; i++)
{
//判断被选中的有哪些。对应的image[]里的哪几张
}
{
this.pictureBox1.Image = Imgs[this.listView1.SelectedIndices[i]];
}可以试试这个
这个i使用点击的索引。for循环肯定是遍历到最后一张显示了呵呵
记得移除的时候也要移除Image[]中对应的大图
{
for (int i = 0; i < this.listView1.SelectedItems.Count; i++)
{
listView1.Items[this.listView1.SelectedIndices[i]].Remove();
}
}
for (int i = 0; i < this.listView1.SelectedItems.Count; i++)
{
listView1.Items[this.listView1.SelectedIndices[i]].Remove();
imageList1.Images.removeAt(i);
imgs.removeAtI(i);
}
for (int i = 0; i < this.listView1.SelectedItems.Count; i++)
{
listView1.Items[this.listView1.SelectedIndices[i]].Remove();
imageList1.Images.removeAt(i);
imgs.removeAt(i);
}
foreach(listViewItem item in listView1.SelectedItems)
{
this.listView1.Items.Remove(item);
}