Reputation: 2137
When creating form windows, often there are situations where a particular event was added and the program comipled.However later u realize that the event is not really required and so remove the event. Now when u compile the code again an error is displayed. For example in the code I have written: WindowsAplication1.LanMessenger does not contain a definition for 'textBox1_click'.
Obviously it es evident that i removed the event textBox1_click after compiling it once before. Is there any way this can be avoided because it does get a touch annoying when you know there is no prob actually.. Please help.
Upvotes: 0
Views: 383
Reputation: 754515
The cleanest way to avoid the error is to do the following
There is no one step way to delete both the event and the event connection in VS 2005/VS 2008. Personally I do the following because I find it to be faster
This is a really fast progression if you use ViEmu :)
Upvotes: 2
Reputation: 82325
You need to look in the MyFormName.Designer.cs and look for the area where your particular controls properties are set. You should notice a line to the effect of:
this.textBox1.Click += new EventHandler(textBox1_click);
You need to remove this line and save the file.
Just a note, these are considered designer generated events, what you could do is wire up your own events for your controls either in your constructor (after the call to InitializeComponent
) or in a Form_Load
event that you can also setup in the constructor. This method is nice because you have clear control and ability to see exactly what handlers are setup.
Upvotes: 4