Please tell me the newcomer, you need to select several random values from the data array and output them as pictures
How to bind to each value in an array or image dictionary and then bring to “Pickerboxes”?
That’s how it turned out to display a random picture by pressing the button.
string [] food = new string [] {"donut", "bread", "water"};
String Randomfood = Food [New Random (). Next (0, Champ.Length)];
TextBox2.Text = Randomfood;
if (randomchamp == "donut")
{
pictureBox2.image = properties.resources.donut_0;
}
if (randomchamp == "Bread")
{
pictureBox2.image = properties.resources.bread_0;
}
if (randomchamp == "Water")
{
pictureBox2.image = properties.resources.water_0;
Answer 1
You will need to call your pictures in the resources exactly as they are named in the array of keys Food
string [] food = new string [] {"donut", "bread", "water"};
String Randomfood = Food [New Random (). Next (0, Champ.Length)];
PictureBox2.image = (Bitmap) properties.resources.resourcemanager.getObject (Randomfood)