Steven
Steven

Reputation: 13769

Quickly Undo Accidental Event Generation

Double-clicking on a control in Visual Studio is a very intuitive way to generate the default event handler. However, I often accidentally double click on a control therefore creating an event handler that I do not need.

Usually, I do one of the following to remove the blank, unused, event handler.

Current methods

  1. Undo (Ctrl+Z): Also performs undo on all unsaved form changes.
  2. Delete Method, Delete Handler: Delete the new method. Delete the event handler in event properties for the control.
  3. Delete Method, Recompile, Select Error, Delete EventHandler in Designer Code: Quicker if code is ready to compile.

Does anyone have an easier way to undo an accidental control event generation?

Upvotes: 3

Views: 233

Answers (2)

CodeCaster
CodeCaster

Reputation: 151654

How to undo an accidental control event generation?

Save often, check in often. When making many tiny changes to something, like a form or database diagram, it helps to have either fast or local version control, so you can perform pretty fine-grained rollbacks in the case you mess something up.

Visual Studio's Undo will only take you back so many steps if the designer allows it, while a commit / shelve after each action (adding a control or database table, changing certain properties) creates a fixed point in time to which you can return.

Upvotes: 1

ChronosMOT
ChronosMOT

Reputation: 341

You can just delete the handler in the event properties as in point 2. This should completely remove the event.

Upvotes: 2

Related Questions