I am scanning the images via WIA and saving the images in List. What I want is, I want to save the get the images from the list and show them in the listview. But I am getting a strange problem. When I click Scan button in my c# window application my list saves only latest image and my List counter doesn't increases to 2 it always remains 1. So my list only save the latest image and overwrite the previous image. Here is my code when I click Scan Button:
List<Image> images = WIAScanner.Scan((string)lbDevices.SelectedItem);
ImageList imageList1 = new ImageList();
foreach (Image image in images)
{
pictureBox.Image = image;
imageList1.Images.Add(image);
}
this.listView1.View = View.LargeIcon;
imageList1.ImageSize = new Size(90, 90);
listView1.LargeImageList = imageList1;
for (int j = 0; j < imageList1.Images.Count; j++)
{
ListViewItem item = new ListViewItem();
item.ImageIndex = j;
this.listView1.Items.Add(item);
}
I suppose the code you posted, is the code which is lying behind your scan button's click event. If so, put the following line out of the click event.
ImageList imageList1 = new ImageList();
With this line you will reset your ImageList, everytime you start a new scan. Put this line outside your click method and all should be fine.