locked
Imagelist help needed RRS feed

  • Question

  • Hello 

                 i want to retrive an image for image folder and set to listView imagekey

    as follows  

    listView1.Items[i].ImageKey = imageName;

     

     

     


    It's Me
    Monday, May 30, 2011 3:36 PM

Answers

  • Hi It_s,

    If you want to retrieve the iamges form the image folder in the runing time. You can try the code as follows: 

    ImageList images = new ImageList();
          String[] filenames = Directory.GetFiles("YourIamgeFolder");
          foreach (String filename in filenames)
          {
            Image image = Bitmap.FromFile(filename);
            images.Images.Add(image);
          }


    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by It_s Meee Thursday, June 2, 2011 5:00 AM
    Wednesday, June 1, 2011 2:35 AM

All replies

  • Hi

    Set image list to listview and set the image index to the item....for more details check this

    http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.aspx


    Regards, Kris.
    Monday, May 30, 2011 4:10 PM
  • hello

              thanks for reply . but i want to retrive from images folder at runtime.

     

    regards

     


    It's Me
    Tuesday, May 31, 2011 5:20 AM
  • Hi,

     

    load the image from file, resize it into a copy, dispose the original, plug the resized one into your imagelist and set the imageindex of the item that shall be associated with that image.

    Regards,

      Thorsten



    Tuesday, May 31, 2011 3:26 PM
  • Hi It_s,

    If you want to retrieve the iamges form the image folder in the runing time. You can try the code as follows: 

    ImageList images = new ImageList();
          String[] filenames = Directory.GetFiles("YourIamgeFolder");
          foreach (String filename in filenames)
          {
            Image image = Bitmap.FromFile(filename);
            images.Images.Add(image);
          }


    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by It_s Meee Thursday, June 2, 2011 5:00 AM
    Wednesday, June 1, 2011 2:35 AM