从其他 class 向表单添加控件

Adding control to form from other class

我正在尝试在 class 中创建图片框并使用方法将其添加到表单中,它没有任何错误但不显示图片框

Class:

class Igrac
{
        public int ID;
        public string Ime;
        public int Polje;
        public int Novac;
        public Igrac(int id, string ime, int polje, int novac)
        {
            ID = id;
            Ime = ime;
            Polje = polje;
            Novac = novac;
        }
        public void Pijun (int LocX,Image image, Form1 form)
        {
            PictureBox pijun = new PictureBox();
            pijun.Size = new Size(20, 40);
            pijun.Location = new Point(LocX,655);
            pijun.Image = image;
            form.Controls.Add(pijun);
        }
}

主程序:

private void Form1_Load(object sender, EventArgs e)
{
    Igrac igrac1 = new Igrac(1, ImeIgraca1, 0, 10000);
    igrac1.Pijun(643, Properties.Resources.Pijun1,this);
}

我已经粘贴了你的代码并且它工作正常,但是检查 new Point(LocX, 655) 构造函数中的参数。如果它大于表单大小,控件将在外部 window,因为 (0,0) 点在左上角。

被另一个控件覆盖了...