Q:

How do I close the application when I click the cross in the title bar when I have several forms?

I have searched through stackoverflow and has found similar question.
As I am still a beginner in C# programming, I could not quite understand what the solutions meant.
I have a c# windows form application that has several forms.
As it only closes when I closes the main form, how do I code it such that when I close other form the application closes as well?
EDIT: most people has told me to code it in the closing event. may i know where is the event found at? thanks.

A:

Not sure why you think out answers will be any easier than ones you have found already but..
A Form has an event called "Closing" (See Here). You should handle the event and then inside that function you can use the following line to close your application...
System.Windows.Forms.Application.Exit();

NOTE: This is for a WinForms application
EDIT:
You can register the closing event using VS designer mode like this...

Select the form
Go To the "Events" window
Double click the "Closing" event option

More detailed answer here
(Google if you cannot work this out)
or you can register the event in code like this...
//In Form constructor function
this.Closing += new EventHandler(Form1_Closing);

private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
   //Handle event here
   System.Windows.Forms.Application.Exit();
}

