- May 7, 2013
- 10,400
Code:
private void Form1_FormClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (MessageBox.Show("Do you want to exit?", "Test", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
e.Cancel = true;
}
}
When the red X is clicked by the user, a message box is meant to appear, asking if they wish to close the program. This message box doesn't seem to appear.
Any suggestions would be appreciated :)
EDIT:
Code:
public Form1()
{
InitializeComponent();
this.FormClosing += Form1_FormClosing;
}
Added this Event Handler, and the program now works as it should do :dance: