Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2008 Windows Forms make "View Code" the default for UserControls

We have some UserControls that can not be designed. So the Windows Forms Designer in VS 2008 is pretty much useless and it takes some time until the designer throws the exception when accidentally doubleclicking the UserControl in the solution explorer. Is there a way I can make the designer open the C# code view when doubleclicking on a UserControl file?

like image 683
bitbonk Avatar asked Aug 07 '09 06:08

bitbonk


2 Answers

I set up all of my forms to open in code view by default by right clicking on one, and selecting the "Open With..." option. From the dialog that appears, select the "CSharp Editor" option and click the "Set as Default" button, then "OK".

You can do the same with user controls, and other types too.

like image 102
Rhys Jones Avatar answered Nov 11 '22 01:11

Rhys Jones


If you want to control this on a file by file basis, add the following attribute to your controls that you want to open in the source code editor:

[System.ComponentModel.DesignerCategory("")]
public class MyControl : Control
{
}
like image 1
NascarEd Avatar answered Nov 11 '22 01:11

NascarEd