我是 C# 新手
我遇到了一些问题,我正在通过 Form.cs[Design] 在 Form1 中创建一些图片框
我想从 Form1 访问图片框
所以我必须在其他类上创建一个对象才能访问 Form1.picturebox1
但我能做对,有人能帮帮我吗
namespace RaceGame{
class Greyhound
{
Form1 runner;
public int StartingPosition = 13;
public int RacetrackLength = 420;
public PictureBox MyPictureBox = null;
public int Location = 0;
public Random Randomizer;
public void Run()
{
runner.pictureDog1.Location = new Point(13, 100);
}
}
这是Form1
namespace RaceGame{public partial class Form1 : Form
{
Greyhound racing = new Greyhound();
public Form1()
{
InitializeComponent();
}
private void raceButton_Click(object sender, EventArgs e)
{
racing.Run();
}
}
}