blah blah blah is here! blah blah » Close

up1down
link

hello,
i want to know how to do like this


private void Form1_unLoad(object sender, EventArgs e)
{
MessageBox.Show("Are You Sure?");
}

last answered 2 years ago

1 answers

link

You need to handle Form1's FormClosing event (add the skeleton handler from the Properties Box):

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult dr = MessageBox.Show("Are you sure you want to quit the application?", "Confirmation required", MessageBoxButtons.YesNo);
if (dr == DialogResult.No) e.Cancel = true;
}

If the user clicks the 'No' button, the closure of the form (and hence the application) will be cancelled.

king_888
153

thank you for the good answer

Feedback