Forcing Visual Studio to open files with the code editor

Alright. I’ve relearned to do this by trawling the internet for the last time.  Yesterday, I upgraded our development environment from Visual Studio 2008 to 2010. At the time it went swimmingly.  Since then, I’ve been plagued with “little” issues like strange reference breakages in assemblies, and the bugbear that this post is about.

There are library files within the solution that contain things that “could” be built up with the VS Designer (sub-classes to DataTable are a perfect example but there are others).  I don’t want or need the designer to step in and try doing its magic on them. It won’t anyway because they occupy the same file as a bunch of other support classes clustered around similar roles and unless a single designable class is at the top of the file, badness happens.

What I want is to get the file to open by default in the code editor instead of the design (GUI) editor that you get if VS notices one of these “designable” classes in a file. The fact that this has come back just after the upgrade makes me suspicious that certain settings were forgotten in the process.

So, first off, here’s a screenshot of a file I’ve just double-clicked on in the solution explorer, containing one of these designable classes, and the design “error” screen I get back:

Visual Studio Designer Error Screen

Visual Studio Designer Error Screen

So, when I hit this issue, I need to right-click on the offending file and choose the “Open With…” popup menu item thusly:

Choosing "Open With..." on a Visual Studio File

Choosing "Open With..." on a Visual Studio File

What I get is a dialog listing a number of editor types I can open the file with (below).  Pay particular attention to the entry with “(Default)” after it.  This is the one you’ll get if you double-click the file from the solution explorer.

"Open With..." Dialog for a Visual Studio File

"Open With..." Dialog for a Visual Studio File

On the right-hand side of this dialog is a “Set as Default” button.  I choose the entry that I’d rather as the default, hit that button and whallah! Opening the file behaves the way I want by default. So, here’s a final screenshot where I’ve chosen the Visual Basic Editor instead of the Windows Form designer as my default editor.

Choosing Visual Basic Editor as the default

Choosing Visual Basic Editor as the default

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s