In C #, the easiest trick for this is to change the entry point of the application in the program.cs file. This input form should be hidden at startup, but will invoke the main form. Then call Application.Exit (); function in the closing procedure in any other form / class.
Pseudo code example below
Program.cs
//edit this line Applcation.Run(startupForm);
StratupForm.cs
//startup method StartupForm_load (object e) { this.Hide(); MainForm mainForm = new MainForm(); mainForm.show(); }
MainForm.cs
//application exit method MainFormExit_close (object e) { Application.Exit(); }
You should probably implement a more accurate way to manage and track open forms later in your program.
source share