• 0

[C#] PictureBox trouble


Question

I can change the image in a PictureBox to a picture stored in my resources by using the following...

userAvatar.Image = new Bitmap(Properties.Resources.wario);

However, i dont want to hardcode this "wario" image into the picturebox. I want the option to insert any image by means of a string...

string myImage = "Properties.Resources.mario";
userAvatar.Image = new Bitmap(myImage);

How can this be achieved. I have searched the internet but cant seem to find an answer.

Thanks... and happy christmas guys :p

Edited by Guest
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Thanks Kristian... based my solution on your code...

string myImage = "mario";
userAvatar.Image = (Image)Properties.Resources.ResourceManager.GetObject(myImage);

:D

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.