المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : problem with registering flormclosing event with button click event



C# Programming
06-17-2009, 12:01 PM
i'm try to register a formclosing event with a button click event but i get the error saying "Cannot assign to 'button1_Click' because it is a 'method group'"

this is the code i'm using



private void Form1_FormClosing(object sender,EventArgs e)
{
DialogResult ds = MessageBox.Show("exit?", "exit", MessageBoxButtons.YesNo);

FormClosingEventArgs ee = (FormClosingEventArgs)e;

if (ds == DialogResult.Yes)
{
ee.Cancel = false;
}
else
{
ee.Cancel = true;
}
}


private void Form1_Load(object sender, EventArgs e)
{
button1_Click+= Form1_FormClosing;
}



what might be the problem here ? http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif