0

I am trying to do something using Resource values but it isn't really working out for me at the moment. I currently have a Windows Forms application which uses a picturebox. I have two pictures set in my project resources ( X and Y ).

What i'm trying to achieve is the following :

pictureBoxTurn.Image = Properties.Resources.( either X or Y goes here hard-coded );

I have a method which returns X OR Y based on certain checks. I'm trying to put the return value up there instead of the hard-coded piece.

pictureBoxTurn.Image = Properties.Resources.( returned X/Y );

I was thinking about putting the return value in a local var, which I could use instead of the hard-coded piece. I'm sorry if I am being unclear but I have no idea on how to search for this problem. I tried, but simply enough couldn't find similar questions.

I'm still learning so my ways aren't perfect. Thank you for reading my question!

Sochi
  • 3
  • 1

1 Answers1

0
string imageToReturn = GetImageToReturn();

object obj = Properties.Resources.ResourceManager.GetObject(imageToReturn, resourceCulture);
pictureBoxTurn.Image = (System.Drawing.Bitmap)obj;
Jon
  • 3,230
  • 1
  • 16
  • 28