无法隐式转换类型' System.Drawing.Image' to' System.Windows.Forms.PictureBox'

时间:2015-08-06 06:45:16

标签: c#

我一直在尝试设置一个随机数生成器,用于显示0到52之间的数字,然后将图片框更改为图像列表中的相应图片,但我不断收到此错误消息

  

无法隐式转换类型' System.Drawing.Image'至   ' System.Windows.Forms.PictureBox'

Random ran = new Random();
int RandomNumber = ran.Next(0, 52);
PicPlayerCard1 = imgCards.Images[RandomNumber];

1 个答案:

答案 0 :(得分:3)

代码中的

Bundle extras = intent.getBundleExtra("key"); 类型为PicPlayerCard1,而非PictureBox

类PictureBox中有一个名为Image的属性,因此您应该使用它:

Image
相关问题