简体   繁体   中英

Load Image from My.Resources to a Picturebox (VB.NET)

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM