lundi 16 mars 2015

Prevent multiple instances winform [duplicate]


This question already has an answer here:




I've got three forms, Form1, Form2, Form3. I need to naviage between this 3 forms, like


From Form1 i need to open Form2 and close Form1 and I do it like this:



Form2 myForm = new Form2(user_form1); // Initialize Form2
this.Hide(); // hide Form1 -> This doesn't hide everytime
this.Close(); // close Form1 -> This doesn't close everytime
myForm.ShowDialog(); // open Form2


but sometimes Form1/Form2/Form3 doesn't want to hide and close, next Form is open but previous form is opened too ( but I can't click on it and do anything ).


What Can i do to prevent it? Any ideas?


Aucun commentaire:

Enregistrer un commentaire