Visual Studio C# - X Button only closes one form rather than the whole program

Viewed 2459

So my issue is pretty straight-forward, I have a program with a login feature, and if all goes well it will open up another form and hide itself.

My issue is that in the new form that opens, hitting the X button to close the window will only close the form but leave the other one running, along with the process.

I have a quit button that shuts down the program, but is there any way to make the X button shut down the program entirely?

Thanks!

4 Answers

If u have Form1, Form2 and need close Form2 in Close button write

this.Close();

If need close Form1(Main) then

Application.Exit();
Related