C# Winform窗口只打开一次
private void OpenForm_Click(object sender, EventArgs e) { Form f = Application.OpenForms["Form1"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { Form1 fa = new Form1(); fa.Show(); //重新new一个Show出来 } else { f.Focus(); //打开过就让其获得焦点 } }
private void OpenForm_Click(object sender, EventArgs e) { Form f = Application.OpenForms["Form1"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { Form1 fa = new Form1(); fa.Show(); //重新new一个Show出来 } else { f.Focus(); //打开过就让其获得焦点 } }