Search code examples
visual-studioide-customization

How to customize the method templates in Visual Studios


Is there a way to customize/edit the default template of the event handling methods in Visual Studios 2008/2010 such that upon creation, the event handler already has a try/catch block in it?

the default behavior is

    private void button1_Click(object sender, EventArgs e)
    {
    }

I'd like to be able to set the development environment to do

    private void button1_Click(object sender, EventArgs e)
    {
        try
        {
            ///TODO: Add logic here
        }
        catch
        {
            throw;
        }
        finally
        {
        }
    }

I've already edited the templates located in the ItemTemplates folder so that they meet the coding standard where I work, but I'd also like to edit the method templates if possible. I've searched the 'Net for the better part of a week and found nothing. Any assistance would be greatly appreciated.


Solution

  • ![Snippet Manager1

    Have you considered Editing Event method stub in the Code Snippet manager or adding a new snippet?