简体   繁体   中英

How do I get an image assigned to a variable to show in a picture box?

Please, why doesn't my image show in the picture box when I assign the path to a variable name in visual c#? For example:

textBox1.Text = "\""+pictureBox1.FileName+"\"";
pictureBox2.ImageLocation = @textBox1.Text;

But it opens if I enter the path directly.

Shouldn't it be pictureBox2.ImageLocation = @(textBox1.Text); ?

Are you using a relative path? If yes, make sure to check if the image is getting copied to the output directory. You do so by set the property as Copy to Output Directory to Copy if newer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM