You are trying to set an event handler for a FormClosing event to the click event of a label.
The two events have different signatures and thus are incompatible.
label_click(object sender, EventArgs e)
MyForm_FormClosing(object sender, FormClosingEventArgs e)
If your intention is to close the application when the user clicks on the label then you need to change your event handler to
label_click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure you want to exit?", "Confirmation",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.Close();
}
}
if your intention is to ask for a confirmation whenever the user tries to exit the application then you need to add a FormClosing event handler to your form and then write
MyForm_FormClosing(object sender, FormClosingEventArgs e)
{
// NOTE, you don't want to abort closing when Windows shutdown, right?
if(e.CloseReason == CloseReason.UserClosing)
{
if (MessageBox.Show("Are you sure you want to exit?", "Confirmation",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
DialogResult.No)
{
e.Cancel = true;
}
}
}