Question

I'm having trouble loading an image from My.Resources. I have already tried a no. of codes like....:

  1. PictureBox1.Image = My.Resources.Online_lime_icon; And

  2. PictureBox1.Image = CType(My.Resources.ResourceManager.GetObject("Online_lime_icon"), Image)

but it would still return:

Picturebox1.Image = Nothing
Était-ce utile?

La solution

Try to convert it ToBitMap()

 PictureBox1.Image = My.Resources.Online_lime_icon.ToBitmap()

EDIT:

@user1615710 : My.Resources.Online_lime_icon doesn't have .ToBitmap. It only has .ToString.

That means you've String resource and I think it represents fileName with or without absolute path.

Try to print/show the content of My.Resources.Online_lime_icon

 Debug.Print(My.Resources.Online_lime_icon) 'or
 MsgBox(My.Resources.Online_lime_icon)

If it is real path then load the image via,

 PictureBox1.Image = Image.FromFile(My.Resources.Online_lime_icon)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top