I'm working on project with sign in feature
When I run the project there is a form (form1
) run the sign in .
after i click on login button build another form (form2
) - It's the form of my program .
and made the first form (form1
) hide .
The problem is when I press at the X button in form2 it's close but the form1 it's still running .
I tried to close the form1
instead of hide ... but this will close form2
before launching
In form1
:
this.Hide();
Form2 x = new Form2();
x.Show();
I think you have your forms around the wrong way.
Form1 sould be your app and shold show Form2 as a dialog when it first loads, then when it closes you can process the result and decide wether to continue or close the application.
Something like:
You go to your form2 then in the event of the form look for FormClosed.
Put this code in your eventhandler:
FormClosed is the event whenever the user closes the form. So when you close the form put a code that will exit your application that is -applicationn.exit();-
Hope this will work.
try this, in the log in button if access is granted
then in form2 if you want to exit
hope this helps.
You could subscribe to the child forms
FormClosed
event and use that to callClose
on the parent form.