Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 806
Steven Avatar asked May 02 '26 22:05

Steven


2 Answers

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

like image 77
ChronosMOT Avatar answered May 04 '26 11:05

ChronosMOT


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.

like image 31
CodeCaster Avatar answered May 04 '26 11:05

CodeCaster