How do I kill a windows form application other than clicking the x button. More specifically, I need to close the program from a menu option. I am coding this in c# 2010.
+1
A:
You mean Application.Exit()
? It can be called from any block of code, such as a menu option or a button click.
David
2010-10-03 22:26:52
A:
You need to assign a custom handler to your menu item's OnClick event handler:
(Pseudocode)
MenuItem_CloseWindow.OnClick += new OnClickHandler(YourMethodHere)
....
YourMethod(object sender, EventArgs e)
{
this.Close();
}
That should do the trick.
Jas
2010-10-03 22:48:10
A:
All Windows Forms come with the built-in ability to close them using the System Menu. Just press ALT + SPACE and it will show the Close option unless you have set the ControlBox property to False.
zainnab
2010-10-15 02:21:47