For the beginning I would like to say that this question doesn't require full attention.
Is great if someone answer, if not, <
Let me start present the situation.
When working with C# form I need to create different controls for different tasks.
If I double click on a control, an automated generated code appears.
This is quite good but sometimes I double click by accident. And doing so it reveals an annoying situation in which I have lot of events with no line of code.
I think that in Microsoft Access, when you compile the code, all the events with no line of code, automatically disappear.
And my question is: is it possible to do so in C#?
Marius DUMITRUPosted Jul 28, 2009, 3:21 PM
Perhaps I wasn't very explicit with my question. I know how to delete accidental genereted code manualy. What I am interested in is the posibility to do this automaticaly. Is there a command or an action in C#, a tools that to do that?
JasonPosted Jul 28, 2009, 12:01 PM
this.Load += new System.EventHandler(this.MainFormLoad);
this.Load is the Load event, and this.MainFormLoad is the event handler.
If you accidentally double click a button, like Button1, you will have to find the event handler assignment that was added and delete it from the form.designer.cs file and delete the event handler method from the form.cs file.
//form.designer.cs
.
.
.
this.Button1.Click += new System.EventHandler(this.Button1_Click); //delete this
.
.
.
//form.cs
.
.
.
void Button1_Click(object sender, EventArgs e) //delete this method
{
}