views:

47

answers:

1

When assigning a function to an event and pressing tab Visual Studio helps by putting a default function name. For instance, when I type:

qp12.Form.OnGetHtml +=

and press tab Visual Studio completes this line as follows:

qp12.Form.OnGetHtml += new GenericForm.DelegateGetHtml(Form_OnGetHtml);

If I press tab once again VC will generate a method stub.

Is it possible to redefine the default function name generated by VC to a concatenation of object, property and event name? For instance:

qp12.Form.OnGetHtml += new GenericForm.DelegateGetHtml(qp12_Form_OnGetHtml);

I can refactor the name after creating the method stub but I am looking for a faster solution.

A: 

I do not believe this is possible sorry.

That said if you are doing this a lot with one liner functions then you should consider writing it in lamdda style instead:

 qp12.Form.OnGetHtml += x =>  DoSomeThingWith(x);

If the functions are sizable then do it this way instead:

 qp12.Form.OnGetHtml += DoSomeThing;

Then you can use visual studio's Generate Method Stub to actually create the method.

This is only one extra key press and results in (to me) much more readable code.

ShuggyCoUk