Listview Control problem - thumbnail display
-
Hi, I previously created clickable thumbnails by assigning them to a picturebox instance and then adding them to the flowlayoutpanel. So i now i decided to experiment with listview control and ImageList control. I would like to display the thumbnail and the image title. Then once you click on the thumbnail the image appears at its original resolution. But i'm having some issues and I would appreciate if you could help me please regarding this? Firstly, I am trying to use an exisiting class that I created which would take in the filepath of the selected image which would then allow me to view the image at its original resolution. Intially the problem i had regarding the listview was when i click on an image, the selected image didnt come up, another image came up. For example i loaded 2 images. One called GoldFish.jpg and the other Rabbit.jpg. But when i click on Goldfish, rabbit appears instead. When i click on Rabbit, Rabbit appears as expected. I think it is something to do with the index possibly? I have now modified the code so that the in the ImageList i add the key and the actual image. So i decided to store the filepath and the thumbnail. Regarding the ListView i decided to store the filename along with the filePath e.g "rabbit.jpg", "c:\\sample\\rabbit.jpg" I then used the mouse click event to access the filePath and pass it into another form. The following snippet is also causing an issue too:
/if i take this code out, the thumbnails are not displayed but if i click on
//the area where the image is supposed to be, I am able to view the desired image at full res.
for (int j = 0; j < pathes.Length; j++)
{
this.listView1.Items[j].ImageIndex = j;
}But if i use the above code then the thumbnails appear but when i click on the image i get the following error message on the click event of the list view.
"Path is not of legal form".
I just want to display the thumbnail images with the filename and when you click on the image you can view the image at its original resolution. Here is my full code.
private void Form1\_Load(object sender, EventArgs e) { imageList1.ImageSize = new Size(108, 108); imageList1.ColorDepth = ColorDepth.Depth24Bit; string\[\] pathes = new string \[\] { @"c:\\\\sample\\\\Goldfish.jpg", @"c:\\\\sample\\\\Rabbit.jpg" }; foreach (string path in pathes) { string\[\] currentPath = path.Split(n
-
Hi, I previously created clickable thumbnails by assigning them to a picturebox instance and then adding them to the flowlayoutpanel. So i now i decided to experiment with listview control and ImageList control. I would like to display the thumbnail and the image title. Then once you click on the thumbnail the image appears at its original resolution. But i'm having some issues and I would appreciate if you could help me please regarding this? Firstly, I am trying to use an exisiting class that I created which would take in the filepath of the selected image which would then allow me to view the image at its original resolution. Intially the problem i had regarding the listview was when i click on an image, the selected image didnt come up, another image came up. For example i loaded 2 images. One called GoldFish.jpg and the other Rabbit.jpg. But when i click on Goldfish, rabbit appears instead. When i click on Rabbit, Rabbit appears as expected. I think it is something to do with the index possibly? I have now modified the code so that the in the ImageList i add the key and the actual image. So i decided to store the filepath and the thumbnail. Regarding the ListView i decided to store the filename along with the filePath e.g "rabbit.jpg", "c:\\sample\\rabbit.jpg" I then used the mouse click event to access the filePath and pass it into another form. The following snippet is also causing an issue too:
/if i take this code out, the thumbnails are not displayed but if i click on
//the area where the image is supposed to be, I am able to view the desired image at full res.
for (int j = 0; j < pathes.Length; j++)
{
this.listView1.Items[j].ImageIndex = j;
}But if i use the above code then the thumbnails appear but when i click on the image i get the following error message on the click event of the list view.
"Path is not of legal form".
I just want to display the thumbnail images with the filename and when you click on the image you can view the image at its original resolution. Here is my full code.
private void Form1\_Load(object sender, EventArgs e) { imageList1.ImageSize = new Size(108, 108); imageList1.ColorDepth = ColorDepth.Depth24Bit; string\[\] pathes = new string \[\] { @"c:\\\\sample\\\\Goldfish.jpg", @"c:\\\\sample\\\\Rabbit.jpg" }; foreach (string path in pathes) { string\[\] currentPath = path.Split(n
you used line:
string[] pathes = new string [] { @"c:\\sample\\Goldfish.jpg", @"c:\\sample\\Rabbit.jpg" };
Lose either @ or replace '\\' to '\'. If you use @, then string will ignore escape characters.
-
you used line:
string[] pathes = new string [] { @"c:\\sample\\Goldfish.jpg", @"c:\\sample\\Rabbit.jpg" };
Lose either @ or replace '\\' to '\'. If you use @, then string will ignore escape characters.