Quote:
2. this.close(); // this code exits the complete program
No, if
this
is the main form, then the code exits the complete program (if
this
isn't the main form, then the particular form will be closed). If you want to execute some code after the form is closed, then go to your Program.cs file, and try this:
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
If you don't add code after the
Application.Run
line, then nothing will be executed if the main form is closed, and then the application closes.
Also, C# is case-sensitive, so don't use
this.close()
, but
this.Close()
, also use
this.Hide()
instead of
this.hide()
, and use
Application.Exit()
instead of
application.exit()
.
Hope this helps.