[英]Cannot Implicitly Convert type 'System.Drawing.Image' to 'System.Windows.Forms.PictureBox'
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 我一直在尝试设置一个随机数生成器,该生成器会显示一个介于0到52之间的数字,然后将一个图片框更改为imagelist中的相应图片,但是我一直收到此错误消息
Cannot Implicitly Convert type 'System.Drawing.Image' to 'System.Windows.Forms.PictureBox'
无法将类型'System.Drawing.Image'隐式转换为'System.Windows.Forms.PictureBox'
Random ran = new Random();
int RandomNumber = ran.Next(0, 52);
PicPlayerCard1 = imgCards.Images[RandomNumber];
PicPlayerCard1
in your code is of type PictureBox
, not Image
. 您代码中的
PicPlayerCard1
是PictureBox
类型,而不是Image
类型。
There is a property named Image in the class PictureBox, so you should use it: 在PictureBox类中有一个名为Image的属性,因此您应该使用它:
Random ran = new Random();
int RandomNumber = ran.Next(0, 52);
PicPlayerCard1.Image = imgCards.Images[RandomNumber];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.