Unable to assign picture from imagelist to picture box

Sindhu H 201 Reputation points
2021-08-11T11:33:38.057+00:00

I am currently using Microsoft Visual Studio Community 2019
Version 16.10.2.

I am getting the following error
'ImageList.ImageCollection' cannot be converted to 'Image'. image ring trial

Developer technologies | VB
{count} votes

Accepted answer
  1. Castorix31 90,686 Reputation points
    2021-08-11T11:43:46.66+00:00

    This basic test works for me :

                Dim imageList1 = New ImageList()
                imageList1.ImageSize = New Size(255, 255)
                imageList1.TransparentColor = Color.White
                imageList1.Images.Add(Image.FromFile("E:\\Hulk.png"))
                Dim img As Image = imageList1.Images(0)
                PictureBox1.Image = img
    
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sindhu H 201 Reputation points
    2021-08-11T12:12:44+00:00

    Thank you.
    I just needed to replace '[ ]' with '( )'

    This statement was all I needed
    PictureBox1.Image=imageList1.Images(0).

    However, the GIF image I am trying to display in the picture box is a static image.
    Can you pls suggest any solution?

    Thank youu


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.