Your extension will be available shortly on the Visual Studio Marketplace at this link.

EventHandler Naming

Free

Creates better default names for event handling methods in the WinForms designer, WebForms designer and Code editor. Specify names with simple patterns. Optionally simplify event handler setup by using delegate inference.

4.7 Star
(3)
Visual Studio
2015, 2013, 2012, 2010
Download (2,915)
3/26/2015
1.5.0
View
E-mail Twitter del.icio.us Digg Facebook
Add to favorites
Description
Sign in to write a review
Sort by:

4 Star
by Eyal Shilony1 | March 05 2011

Thank you for such great and simple extension.

5 Star
by cpmcgrath | December 23 2010

Fantastic extension. I've always hated how Studio named event handlers. Can't believe I didn't think of making this extension myself.
My only advice is to not have the drop downs all written in Pascal case, write them in their own style...

No Change
lowercase
UPPERCASE
lowerCamelCase
PascalCase

Great work.

Sign in to start a discussion


  • Version for VS2013
    3 Posts | Last post April 08, 2014
    • Hi,
      
      I'm using Visual Studio 2013. Is there a version of the extension for this IDE ?
      
      Thank you
    • Hi
      
      Sorry, I haven't updated yet, and don't have time to do so right now. If you're feeling adventurous you can try updating yourself:
      
      1. Download the vsix file.
      2. Rename it to .vsix.zip
      3. Extract the file extension.vixmanifest
      4. Open it with a text editor
      5. Copy the <VisualStudio Version="11.0"> tag and its contents, and add a new one like except <VisualStudio Version="12.0">
      6. Put the file back in the zip, rename back to .vsix and install.
      
      That should do it. When I get some time I'll try to do it myself and test it in VS2013 to make sure it still works.
    • Well, it took a while but now v1.4 is out which supports VS2013.
  • Don't work with some EventHandler
    2 Posts | Last post September 08, 2011
    • Hi,
      
      I try to use the "Use delegate inference" but when the suggested name by visual studio for the EventHandler has more than just the name of the EventHandler, the code generated is not correct.
      
      Example: I try to attach an event to the ToolClick event of the Infragistics toolbar. When I call my toolbar like that: _toolBar.ToolClick += ... the popup of Visual Studio to complete the instruction is "New Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(_toolbar_ToolClick) 
      
      Because the suggested code by visual studio have the namespace before the EventHandler, when I press Tab 2 times, the result looks like that:
      
      _toolbar.ToolClick += new Infragistics.Win.UltraWinToolbarsOnToolClick;
      
      instead of 
      
      _toolbar.ToolClick += OnToolClick;
      
      but the generated method is correct.
      
      I tried with a lot of cases and the problem is just when in the suggested code by visual studio, there is a namespace before the EventHandler name.
      
      Thank you.
    • Thanks for the bug report. I'll look into it as soon as I have some time, and update when I've fixed it.
  • Does this work for WPF too?
    2 Posts | Last post August 21, 2011
    • ?
    • No, unfortunately the WPF designer offers almost no real extensibility hooks, so I couldn't implement this for that designer. 
  • private handlers
    2 Posts | Last post June 18, 2011
    • A very handy extension - thanks!  Is there a way to add the "private" accessor to the autogenerated handler?
      
      Cheers
      Dan
    • Glad you like it. No, there is no way to change the accessor of the generated method. I hook into what happens before it is generated. I'm working on 2-3 other pet projects right now so I won't be adding the feature myself, but if you want to add the feature yourself it probably wouldn't be a big change, you can fork on github (https://github.com/einaregilsson/EventHandlerNaming) and send a pull request. 
  • Thank you! :)
    1 Posts | Last post June 15, 2011
    • A bit late but still, thank you.
  • Adding a feature.
    3 Posts | Last post April 26, 2011
    • Is there any chance you could add a list of keyword to filter out of the name ?
      
      I tend to use the following prefix("ux") for most of my user controls and so the name of the event would come out as UxSomeButton_Click so currently I have to change it for every single event.
      
      So I think that having some sort of black list that we could add names to filter out of the actual event name would be quite useful. 
      
      e.g. UxSomeButton_Click => SomeButton_Click 
      
      Thank you.
      
    • Sure, I've actually thought about something similar myself, since I often use txtSomething, lblSomething etc. as prefixes for controls. I'll look at it sometime soon and publish a new version when it's done.
    • Well, it took a while but your suggestion is implemented in version 1.2. Unfortunately because of the (admittedly pretty stupid) way I was storing settings you'll lose you settings in the update so you'll have to configure it again but this won't happen in future versions. By default I remove all the prefixes I tend to use for controls, txt;grp;lbl;cbo etc. But you can configure it any way you need.
      
      Enjoy!