C#表格申请从一页移动到另一页

C#表格申请从一页移动到另一页,c#,C#,我正在制作一个游戏。我有一个菜单页面,有一个“开始”按钮。我想知道我如何可以使按钮直接与游戏的新页面的用户。我曾想过简单地将所有按钮和标签的可见性更改为false,但那将非常混乱。我想关闭表单并重新打开一个新表单,如下所述: 像这样: public static void ThreadProc() { Application.Run(new Form()); } private void button1_Click(object

我正在制作一个游戏。我有一个菜单页面,有一个“开始”按钮。我想知道我如何可以使按钮直接与游戏的新页面的用户。我曾想过简单地将所有按钮和标签的可见性更改为false,但那将非常混乱。我想关闭表单并重新打开一个新表单,如下所述:

像这样:

public static void ThreadProc()
        {
            Application.Run(new Form());
        }

    private void button1_Click(object sender, EventArgs e)
    {
        System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc));
        t.Start();
        this.Close();
    }
但是当我单击按钮时,您可以看到表单关闭并再次打开,它甚至没有在相同的坐标下重新打开。
有没有办法做这样的事?我希望它从一个页面移动到另一个页面,就像这是一个网站一样。这可能吗?如果是,怎么做?提前感谢:-)

对需要的每个视图使用
UserControl
s,然后通过在表单中添加/删除它们在代码中进行切换

示例:开始页面是一个
UserControl
,其中包含启动游戏的按钮。游戏UI是另一个
UserControl
,包含游戏的所有逻辑和视觉效果

然后,您可以使用以下内容:

public class StartView : UserControl
{
    ...

    private void btnStart_Click(object sender, EventArgs e)
    {
        // Raise a separate event upon the button being clicked
        if (StartButtonPressed != null)
            StartButtonPressed(this, EventArgs.Empty);
    }

    public event EventHandler<EventArgs> StartButtonPressed;
}

public class GameView : UserControl
{
    ...
}

public UserControl SwitchView(UserControl newView)
{
    UserControl oldControl = null;
    if (this.Controls.Count > 0)
    {   oldControl = (UserControl)this.Controls[0];
        this.Controls.RemoveAt(0);
    }

    this.Controls.Add(newView);
    newView.Dock = DockStyle.Fill;

    return oldControl;
}
对按下“开始”按钮作出反应的事件处理程序将执行以下操作:

public void StartButtonPressed(object senderView, EventArgs e)
{
    GameView v = new GameView();
    UserControl old = SwitchView(v);
    if (old != null)
        old.Dispose();
}

创建更多表单。使用时,单击按钮打开下一个表单,而不是关闭并重新打开当前表单。你需要帮助吗?使用面板而不是不同的表格。隐藏当前面板,然后显示下一个面板。为所需的所有表单制定计划。还有他们的关系:他们会合作吗?酒店是否会同时开放,在哪里,尺寸等。。?然后,您可以决定是要多个表单,还是要一个带有tab和tabpages的表单,还是要一个带有面板、用户控件或混合的表单。。
public void StartButtonPressed(object senderView, EventArgs e)
{
    GameView v = new GameView();
    UserControl old = SwitchView(v);
    if (old != null)
        old.Dispose();
}