views:

28

answers:

2

Visual Studio has ways to automatically create a method. For example, you could double click on a button in the designer to create an event handler method or you could use the dropdown boxes at the top of the code editor to create an override or an event handler.

For me, these methods seem to never place the new method at a reasonable place in the code. For example, at the end of the source file would seem reasonable. But there must be some reasoning behind how these operations work. How can I understand what Visual Studio is doing and take advantage of it to minimize the frustration. (My current strategy is to avoid the ways that automatically create these methods and just type them where I want them in the first place!)

+1  A: 

VS2008 places all event handlers that it creates when you double click on a control at the end of the file. Extract Method places the new method right below the original method. But you know, you can actually move the automatically created methods wherever you want...

I believe Refactor! lets you choose where you want the methods placed it creates.

EricSchaefer
A: 

Both VB.Net and C# will place the method created after the last method defined in the primary class file. With partial classes, it's the file which is not the .designer file.

Can you give us some more information on your scenario? What language, designer and version of visual studio?

JaredPar