Random PictureBox windows forms c#

  • Thread starter Thread starter KipkesZijnGeil
  • Start date Start date
K

KipkesZijnGeil

Guest
I'm making something in windows forms. In my project I have 190 picture boxes. I want to take a random picturebox. They are all called picturebox1, picturebox2,... ect. Here is what I want to do.


if(month == 1)
{
pictureBox Here a random number (0-190) .Image = MemoryGame.Properties.Resources._2__1_;
}


bv.

if(month == 1)
{
pictureBox168.Image = MemoryGame.Properties.Resources._2__1_;
}

how can I do something like this. This doesnt work. :


Random rnd = new Random();
int month2 = rnd.Next(0, 191);
if (month == 0)
{
PictureBox.month2.Image = MemoryGame.Properties.Resources._2__1_;
}

Continue reading...
 
Back
Top