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!

3
  • possible duplicate of C# Resource Array Commented Mar 18, 2015 at 9:29
  • I've tried it. No errors, but no success either. Commented Mar 18, 2015 at 10:08
  • @Sochi If you have tried it and it didn't help, then post the code you tried and describe what and how fails. Commented Mar 18, 2015 at 19:34

1 Answer 1

0
string imageToReturn = GetImageToReturn();

object obj = Properties.Resources.ResourceManager.GetObject(imageToReturn, resourceCulture);
pictureBoxTurn.Image = (System.Drawing.Bitmap)obj;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.