C
C#11mo 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
canton711mo ago
This is WinForms?
sterbuk
sterbukOP11mo 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
canton711mo ago
So you can just assign to .Image? What resource type are your images stored in? Embedded resources, Settings.Resources, etc?
sterbuk
sterbukOP11mo ago
idk, how do I see that
sterbuk
sterbukOP11mo ago
No description
sterbuk
sterbukOP11mo ago
@ me if someone can help me
Omnissiah
Omnissiah11mo 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