I added some buttons to a Form, but doubled clicked the wrong one and that took me to the code editor.
I decided to delete the generated code that resulted from clicking the wrong button. I did a rebuild and ended up getting an error:
Error 1 'xxxxx' does not contain a definition for 'xxxxx' and no extension method 'subtraction_Checked' accepting a first argument of type 'xxxx' could be found (are you missing a using directive or an assembly reference?)
How do I resolve this?
When you double click on button
, it creates an event handler in designer generated code as:
this.button1.Click += new System.EventHandler(this.button1_Click);
and in code editor you will see this:
private void button1_Click(object sender, EventArgs e)
{
}
Now, if you remove only the handler, you will get an error. To resolve this you need to remove the event from designer generated code ie this.button1.Click += new System.EventHandler(this.button1_Click);
Same goes for checkboxes, textboxes and other controls as well.
You have a control on your Form. It called "subtraction". If it is a checkbox, and if you double click on it your developing program auto-generates the event-handler for Checked event. It makes a code in your form's code (the void) and in yor designer file (the calling of the void). I think you deleted only the void. You must go to the designer file and telete the event calling. It looks like:
this.subtraction.Checked += new System.EventHandler(this.subtracion_Checked);
You must delete this line.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.