I am trying to make an app with several random cards drawn on it -- I have added a folder named "resources" to the project and added a few playing card images to it (1.jpg, 2.jpg, etc.).
To fill the picturebox that I have I just made a bitmap including the FULL path --- this is not what I want because this obviously will not be the right path for everyone who downloads and looks at my application.
What path would I use for an image in a folder that has been added to the project???
Below is my clunky code -- any advice would be helpful. I am eventually going to have 21 pic boxes that will be filled by 21 random cards. But for right now I am just trying to figure out the easiest and cleanest way to fill 1 picbox.
private void button1_Click(object sender, EventArgs e)
{
deck myDeck = new deck(2);
Bitmap card1 = new Bitmap("C:\\Documents and Settings\\**\\My Documents\\Visual Studio 2005\\Projects\\theDeck\\theDeck\\resources\\" + myDeck.cards[0].ToString() + ".jpg");
pile1image1.Image = card1;
}

Scott LyslePosted May 30, 2007, 11:41 PM
Todd VancePosted May 30, 2007, 9:03 AM
**IT IS AMAZING how simple this stuff is when you find out how to do it!**
And thanks for your help as well Jan!
Jan MontanoPosted May 30, 2007, 1:57 AM
Scott LyslePosted May 30, 2007, 1:49 AM
pbxCard.Image = Properties.
Resources.HeartsQueen;Since you have your image files in a resources folder, just open up the properties, click on the resources tab, set the resource type to images, and then drag and drop each image onto the resources panel. You should see a thumbnail of each image as an indication of success.
Once added, you can access them using code similar to that shown above.