Reputation: 19
I have been trying to set up a random number generator that pics a number between 0 and 52 and then change a picture box to the the corresponding picture in an imagelist but i keep getting this error message
Cannot Implicitly Convert type 'System.Drawing.Image' to 'System.Windows.Forms.PictureBox'
Random ran = new Random();
int RandomNumber = ran.Next(0, 52);
PicPlayerCard1 = imgCards.Images[RandomNumber];
Upvotes: 1
Views: 3660
Reputation: 2296
PicPlayerCard1
in your code is of type PictureBox
, not Image
.
There is a property named Image in the class PictureBox, so you should use it:
Random ran = new Random();
int RandomNumber = ran.Next(0, 52);
PicPlayerCard1.Image = imgCards.Images[RandomNumber];
Upvotes: 3