C
C#10mo ago
sterbuk

How can I assign a picture to a picturebox in the code?

I want to put multiple pictures in one picturebox, like you click on the button and it changes to a random one. But how do I assign the picture to the picturebox if you what I mean?
7 Replies
canton7
canton710mo ago
This is WinForms?
sterbuk
sterbukOP10mo ago
Yeah Im tryna make like an exercise to practise american states So its gonna give you a picture and you have to type the state and then ask to correct and then I want to show a new state I've got all the pictures in the resources
canton7
canton710mo ago
So you can just assign to .Image? What resource type are your images stored in? Embedded resources, Settings.Resources, etc?
sterbuk
sterbukOP10mo ago
idk, how do I see that
sterbuk
sterbukOP10mo ago
No description
sterbuk
sterbukOP10mo ago
@ me if someone can help me
Omnissiah
Omnissiah10mo ago
to load from a file you set the path in ImageLocation and the use Load (iirc) from a resource, i don't remember, but there are for sure tons of pages describing it in internet oh well apparently you just assign the resource to the image, like
pictureBox1.Image = Properties.Resources.Whatever;
pictureBox1.Image = Properties.Resources.Whatever;
because it's already a Bitmap
Want results from more Discord servers?
Add your server