AndrewMC
AndrewMC

Reputation: 271

How do i remove an event from the code without manually deleting it?

Sometimes when you accidently double click on events it generates the events event method and add and event handler in the InitializeComponent() of the form.

So when I want to delete the event, I have to delete code in two places, the event method it self and the event handler in to InitializeComponent(). But is there away to do this without deleting code manually?

Upvotes: 1

Views: 924

Answers (1)

Riz
Riz

Reputation: 1131

If you have have not edited the event handler body, you can simple remove the event using VS Designer. For this select Events in Properties window and remove the handler that you don't need.

However, if you have edited the event handler (i.e. the body contains some code or comments). You can still remove the event using above step. But from the cs file you have to manually delete the method. This helps to refrain from designer generated code (and possibility of messing it up).

Upvotes: 3

Related Questions