C# 后退按钮工作不正常

C# 后退按钮工作不正常,c#,.net,winforms,C#,.net,Winforms,在父窗体中,我显示多个子窗体,我从child1打开child2,从child2打开child3,直到工作正常,窗体在父窗体中打开,但当我想从child2返回child1时,child1窗体在父窗体之外打开,返回按钮的正确代码是什么 打开代码chil2表单以child1表单编写 private void btnEngClgList_Click(object sender, EventArgs e) { ShowEngClgList engfrm = new ShowEngClgList(L

在父窗体中,我显示多个子窗体,我从child1打开
child2
,从child2打开
child3
,直到工作正常,窗体在父窗体中打开,但当我想从
child2返回child1
时,
child1窗体在父窗体之外打开,返回按钮的正确代码是什么

打开代码
chil2表单
child1表单编写

private void btnEngClgList_Click(object sender, EventArgs e) {
    ShowEngClgList engfrm = new ShowEngClgList(LoginName);
    engfrm.MdiParent = this.ParentForm;
    this.Hide();
    engfrm.Show();
}
private void toolStripBtnBack_Click(object sender, EventArgs e) {
    this.Close();
    MainForm mnfrm = new MainForm(lname);
    mnfrm.MdiParent = this.ParentForm;
    mnfrm.Show();
}
返回按钮代码以
child2表单编写

private void btnEngClgList_Click(object sender, EventArgs e) {
    ShowEngClgList engfrm = new ShowEngClgList(LoginName);
    engfrm.MdiParent = this.ParentForm;
    this.Hide();
    engfrm.Show();
}
private void toolStripBtnBack_Click(object sender, EventArgs e) {
    this.Close();
    MainForm mnfrm = new MainForm(lname);
    mnfrm.MdiParent = this.ParentForm;
    mnfrm.Show();
}
你可以这样做:

((this.Parent) as Window).show();

现在还不清楚你想在这里做什么…当你打开/关闭子窗体时会发生什么?我试图通过简单地创建back按钮在子窗体之间导航。如果你不想创建一个新的主窗体,你已经有了一个主窗体。这是我的父母。你肯定需要重新考虑一下“回头路”将如何发挥作用,因为你还没有接近。这在MDI应用程序中没有什么意义。@Hans Passant这就是我要搜索的,你能提出任何解决方案吗?你能解释一下我应该用什么形式写这个,在哪里写,这行代码会做什么吗?你应该用主形式写它。关闭此窗口后。在这种情况下,它将成为父窗口window1。我在父窗体的
初始化Componenet()
之后编写了它,但是它不工作,并且给我错误,请在此处键入它:private void toolStripBtnBack\u Click(对象发送者,事件参数e)让我们