(behind a button)
Read_QuranoTafsir readQuran = new Read_QuranoTafsir();
readQuran.MdiParent = this;
This is my new form code it is working fine but the problem is
as i click my button a form appear.
i click again another form appear this thing continues as i click again and again.
i want to restrict my form to not open more then 1 if the form is alread active.
Two simple solutions.
Set a flag when you open your form, clear it when you close.
Before you open your form, you check to see if the flag is set - hence the form is open, and you do nothing. If the flag is not set - you open the form.
Alternatively - disable button when the form opens, and reenable it when you close.
Another option would be to make it a field which starts out null. When the user clicks the button, check the field, if null then instantiate and set the field. The problem being that you need to clear the field when the user closes the form.
There are other solutions involving mutexes (mutices?) as well.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)