How to use imageList

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jitheshborgia
    New Member
    • Jul 2009
    • 8

    How to use imageList

    Can anybody send how to use imageList tool? How can we extract the pictures one by one?



    Thank you
    Last edited by jitheshborgia; Aug 1 '09, 02:49 PM. Reason: forget something
  • cloud255
    Recognized Expert Contributor
    • Jun 2008
    • 427

    #2
    Hi

    What exactly do you mean by extract?
    To address a specific image you can use the key of the image:

    Code:
    myImageList.Images["ImageKey"]
    or find it by its index. I suggest supplying a key to each image you add to the ImageList as this makes the code more maintainable.

    Comment

    • jitheshborgia
      New Member
      • Jul 2009
      • 8

      #3
      i mean how we can view the images from imageList?is it possible to add the images to a picture box one by one?

      Comment

      • ThatThatGuy
        Recognized Expert Contributor
        • Jul 2009
        • 453

        #4
        hi !!!

        First drag and drop imageList control from your ToolBox to the form...
        Go to the imagelist properties...an d in there select Images property....sel ect a few images.....
        Set the ColorDepth Property to Depth32Bit..
        this property determines the color resolution of your images...
        Set the ImageSize property to the picture Box size.....
        Put up a button in your form and a picture box too...
        Declare a global variable such as int i=0;
        Now Put up this code into thr button click event
        Code:
         if (i < imageList1.Images.Count)
                    {
                        pictureBox1.Image = imageList1.Images[i];
                        i++;
                    }
                    else
                    {
                        i = 0;
                    }
        this code will show images one by one in the image list.....and will keep revolving...... .

        Comment

        • DumbNewGuy

          #5
          ThatThatGuy was very helpful. It's amazing how hard it is to find a simple answer to this obvious question. Us VB6 guys new to C# .NET probably screw up by trying to use:

          pictureBox1.Ima ge = imageList1.Imag es("MyImageName ");

          That's how it looks in VB6, but here is how it looks in C# .NET (using BMPs imported into the imagelist):

          pictureBox1.Ima ge = imageList1.Imag es["MyImageName.bm p"]

          There is no '.Item' member on the collection to let you use "()" instead of "[]" and the ".bmp" gets automatically included with the filename as the key. So simple! But all the examples are just loading images off the disc to the image list and/or getting the graphics object off the WinForm and drawing the image to that.

          Comment

          Working...