To Prevent Multiple Show of the same Modeless Form

private void findToolStripMenuItem_Click(object sender, EventArgs e)
{
   // 현재 열려있는 비모달형 폼 중복생성 방지
   bool formExist = false;

   foreach (Form f in Application.OpenForms)
   {
     if (f.GetType() == typeof(
FindPersonForm))
     {
       f.Activate();
       formExist = true;
     }
  }
 
  if (!formExist)
 
{
     FindPersonForm f = new FindPersonForm();
     f.Owner = this;
     f.Show();
     f.Activate();
   }
}

Leave a Reply

Your email address will not be published. Required fields are marked *