How to close C# winform when user will click X of form?
Hi All,
When you close winform but did not exit from system then that application is still running in background .
So how to close application properly on click of X button in form.
Solution is Simple:
make a function logout() and add exit code there like below:
private void logout_Click(object sender, EventArgs e)
{
Application.Exit();
}
and either inside InitializeComponent() function or after InitializeComponent() function add below code :
this.FormClosing += logout_Click;
and voila you can close whole application by click of Red X button on form.
Please comment if you have any question.
Thanks
Abhi
When you close winform but did not exit from system then that application is still running in background .
So how to close application properly on click of X button in form.
Solution is Simple:
make a function logout() and add exit code there like below:
private void logout_Click(object sender, EventArgs e)
{
Application.Exit();
}
and either inside InitializeComponent() function or after InitializeComponent() function add below code :
this.FormClosing += logout_Click;
and voila you can close whole application by click of Red X button on form.
Please comment if you have any question.
Thanks
Abhi
Comments
Post a Comment
Thanks for you message, please join us on Facebook and Linkedin