C# Winform 只打开Form窗体一次

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();   //打开过就让其获得焦点
      }
    }


你可能感兴趣的:(object,C#,null,WinForm)