add

June 21, 2009

VB.NET control event handlers are removed after cut and paste. VS2005
How very special that the event handlers disappear without warning in the VS2005 IDE after cutting and pasting controls using the form designer. Hardly noticable until users start to complain that forms are not functional.

Fortunately you can use Regular expressions to find missing event handlers. Using the Find and Replace dialog. Click the "Use:" checkbox and select "Regular Expressions".
In the "Find what:" textbox enter the following:

Private Sub [A-Za-z]+[\_]+[\(A-Za-z\.\,]+[(\))]+

This regular expression will find any Private Sub with an underscore in the name that doesn't have an event handler. So it's very useful if you don't use underscores in your naming conventions except for events.