Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
How to put a variable in the Properties.Resources."image" line.
Todd Vance
17y
4.2k
1
Reply
Hey all,
Last night I was asking how best to add a resource and was given this good advice
"By adding the image files to your resources, you can limit the code needed to display the image to something like this:
pbxCard.Image = Properties.
Resources
.HeartsQueen;"
But my issue I have now is that I wanted to fill these boxes with Random images chosen by an array.
In other words I want something like pbxCard1 to be the
myDeck.cards[0].ToString + ".jpg"
image.
By adding my images to the resources like I was told all my images which were named 1 and 2 and 3.jpg (etc.) get their names changed to _1 and _2 and _3 -- so I somehow need to get the number out of the array and then concatenate it to the end.
NOW I KNEW THIS wouldn't work -
pile1image1.Image = Properties.
Resources
._ + mydeck.card[0].ToString;
but it is in essence what I want to do -- can someone tell me how to do it?
============
ALSO I cant do this:
string
image1 =
"Properties.Resources._"
+ myDeck.cards[0];
because when I try and place it into the pile1image1.Image = image1 line - it tells me that I cannot convert a string to an image.... help???
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
calculating a future date?
First C# Program- Need a Little Help