0

How do I display an image in a picturebox using a variable name?

string name = "photo.jpg";

pictureBox1.ImageLocation = name;

// or

Image image = Image.FromFile(name);
pictureBox1.Image = new Bitmap(image);

neither is working. I'm getting the small box with an x in it.

Any help? Thanks

1
Contributor
1
Reply
3
Views
5 Years
Discussion Span
Last Post by csstu
0

sorry, I figured out what I did wrong. I was using an array and I had the wrong index.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.