As per question. So I have a main window (MainForm) load when application start. Then in MainForm_load event it do showDialog another form (LoginForm.showDialog()).
What I struggling about is, how can if user close the LoginForm (the x sign in the top right corner) it close the application?
in LoginForm there is only one button labeled “Login”
Thx before for the answer 🙂
well I’ve been trying this
private void frmLogin_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
Application.Exit();
}
else
{
this.Dispose();
}
}
but it’s invalid operation exception on Application.Exit()
so what I want is the application exit only if I close this Login form using [x]close button.
Well I shouldnt use the frmLogin_FormClosing event at the first.
I use frmLogin_FormClosed
thanks for all the help and attention guys 🙂