Quang Dinh Luong

Quang Dinh Luong

  • NA
  • 76
  • 18.8k

Check opened FORM!

Oct 11 2015 5:25 AM
I have a new problem! :(
My app have 2 form, I add a button to Form1 so as to open Form2. And now the problem appears, the more I click that button, the more Form2 are opened.
Ex: Click 10 times , 10 Form2 on the screen!
I'v tried this:
     Form2 formTwo = new Form2(); 
    if (formTwo.Visible == false) {formTwo.OpenDIalog();}
     else {formTwo.BringToFront();}
 
But it doesn't work! :(
I've also tried to set Enabled of that button properties to false after Form2 open. But it will make that button's text disapper. So please ignore this!
Is there a way to check if the form2 is opened or not to do different action
Expect model:
    if(Form2 is not opend)  {//Do not open again}
    else{open form2} //I know this, just need the red one
 

Answers (4)