question

SindhuH-2474 avatar image
0 Votes"
SindhuH-2474 asked SindhuH-2474 commented

Unable to assign picture from imagelist to picture box

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

dotnet-visual-basic
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Which code gives this error?


0 Votes 0 ·

PictureBox1.Image=imageList1.Images[0].

0 Votes 0 ·
Castorix31 avatar image
0 Votes"
Castorix31 answered

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SindhuH-2474 avatar image
0 Votes"
SindhuH-2474 answered SindhuH-2474 commented

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

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

However, the GIF image I am trying to display in the picture box is a static image.

I don't understand what you mean by "static image"...


1 Vote 1 ·

I mean the GIF image that i add to the image control will not be "Animated".
Only one image (out of several images from which GIF is created) is displayed, when i run the code.

0 Votes 0 ·

If images are from an ImageList, it is normal
Animated GIF works if assigned directly PictureBox1.Image = Image.FromFile("C:\Animated_Gif_Test.gif")

1 Vote 1 ·
Show more comments