Just deleting the event handler isn't enough. You also need to remove the
line of code that registers the event handler with the event. For example,
to remove the Load event for a form called 'MyForm' you need to delete two
things:
1. private void frmMyForm_Load(object sender, System.EventArgs e) { // some
code } (the event handler)
2. this.Load += new System.EventHandler(this.frmMyForm_Load);
The former is the event handler itself, the latter is the line of code that
attaches this event handler to the Load event. You'll find this line in the
*Windows Forms Designer generated code* region.
There is an easier way to do this, though. Go back to the control's
properties and open the events, just like you did to add the event. Select
the name of the event handler next to the event in the list. Delete this
method from the event list. This will remove the code. If there was no code
in the event handler, the handler itself will also be deleted from your
code. If you already wrote code, you still have to delete this method
manually, but all other code related to this event is removed automatically
by VS.
--
Kai Brinkmann [MSFT]
Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
vbMark said:
If I've added an event that I don't want what's the best way to delete
it?