C#自己的类继承PictureBox没有显示

时间:2017-01-07 13:04:30

标签: c# picturebox

我正在写游戏,我创建了一个继承自PictureBox

的类
class Mashrooms : System.Windows.Forms.PictureBox
{

   public  Mashrooms(int x, int y)
    {

        Name = "mush";
        Location = new Point(x, y);
        Enabled = true;

         //Image = Image.FromFile("mushroom.png");
        ImageLocation = @"mushroom.png";
         Size = new Size(16,32);

    }

}

在form1.Designer.cs中我放了

Mashrooms m = new Mashrooms (200,50);
        this.Controls.Add(m);

即使游戏运行,图片也不会显示。

0 个答案:

没有答案