I have 7 pictures in resources, named 1.jpg, 2.jpg ect..
Then in code I have generated int skaicius, which has value 5...
Now I need on button push avent change the image to skaicius + ".jpg"
and use image from imported resources
It's something like that I think
pictureBox2.ImageLocation = kauliukas + ".jpg";
But It's supposed to load image from local dir as I know... SO how to load it from resources?
As soon as you import your pictures to the Resources (resx) file, the extensions are lost, and for example "ThisPicture.jpg" would be accessed through Properties.Resources.ThisPicture.
Which effectively means you can do the following on your PictureBox:
pictureBox.Image = Properties.Resources.PictureName
Where PictureName is the name of the actual resources according to your Resources file.
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.