Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Listview Control problem - thumbnail display

Listview Control problem - thumbnail display

Scheduled Pinned Locked Moved C#
helpdatabasetutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Eagle32
    wrote on last edited by
    #1

    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
    
    S 1 Reply Last reply
    0
    • E Eagle32

      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
      
      S Offline
      S Offline
      Saksida Bojan
      wrote on last edited by
      #2

      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.

      E 1 Reply Last reply
      0
      • S Saksida Bojan

        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.

        E Offline
        E Offline
        Eagle32
        wrote on last edited by
        #3

        Hi, thanks for the advice. I amended the file path as you advised by using just '\' and it appears to be working. I had to set to the listview properties such as View and LargeIcon before the creation of the images.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups