C# 从应用程序中的任何位置显示隐藏表单

C# 从应用程序中的任何位置显示隐藏表单,c#,winforms,C#,Winforms,我有几张表格 让我们把它们称为indexForm,formOne,formTwo,formThree等等 在indexForm上,有一个按钮转到formOne,该按钮包含以下代码位: private void buttonOpenFormOne_Click(object sender, EventArgs e) { formOne displayformOne = new formOne(); displayformOne.Show

我有几张表格

让我们把它们称为
indexForm
formOne
formTwo
formThree
等等

indexForm
上,有一个按钮转到
formOne
,该按钮包含以下代码位:

private void buttonOpenFormOne_Click(object sender, EventArgs e)
        {
            formOne displayformOne = new formOne();
            displayformOne.Show();

            this.Hide();
        }
要从
formOne
返回到
indexForm
,我只需执行以下操作:

private void buttonGoBack_Click(object sender, EventArgs e)
        {
            indexForm displayIndexForm = new indexForm();
            displayIndexForm.Show();

            this.Close();
        }
现在,如果我从
indexForm
转到
formOne
,这个功能就可以完美运行了。因此,切换回
indexForm
是轻而易举的事。但是,如果我从
formOne
转到
formTwo
,例如,单击按钮时,
indexForm
不会显示

我的问题是,如何才能从应用程序的任何位置全局返回到
indexForm
,或者从应用程序的任何位置显示最初隐藏的
indexForm

试试这个

FormCollection fc = Application.OpenForms;
foreach (Form frm in fc)
{
    if (frm.Name == "FormName")
    {
        frm.Show();
        frm.BringToFront();
    }

}

@Grantwiney,我如何在不创建新实例的情况下切换回原始indexForm,以及如何显示隐藏的实例?@Grantwiney好的。比如说我在二年级,从一年级开始。如何显示隐藏索引表单?创建子表单时,将其父属性设置为当前表单
displayformOne.Parent=this然后,子窗体可以访问父窗体并可以重新显示它。您知道将有多少子窗体吗?@RadioSpace Yes。子窗体的数量是可确定的。