visual-studio Visual Studio:将视图代码设为默认值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/399768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:01:37  来源:igfitidea点击:

Visual Studio: Make view code default

visual-studio

提问by smack0007

Is there any way to make Visual Studio show the code of a control / form by default instead of the designer? I tend not to be a fan of the designers as they add bloat.

有没有办法让 Visual Studio 默认显示控件/表单的代码而不是设计器?我倾向于不喜欢设计师,因为他们会增加臃肿。

回答by Jon Skeet

Right-click on a file and select "Open With..."

右键单击文件并选择“打开方式...”

Select "CSharp Editor" and then click "Set as Default".

选择“CSharp Editor”,然后单击“Set as Default”。

回答by gmb

Decorate your class with [System.ComponentModel.DesignerCategory("")], e.g.:

用 [System.ComponentModel.DesignerCategory("")] 装饰你的类,例如:

[System.ComponentModel.DesignerCategory("")]
public class MySpecialButton : System.Windows.Forms.Button
{
}

回答by ajs410

I like having my forms open up in Design View, but I made a partial class file which had only code and Visual Studio wanted to open it in Design View all the time. To prevent Visual Studio from realizing that a specific source file can be loaded by Designer, look at the csproj file for the Compile Include tag of the appropriate source file and remove the SubType tag underneath it.

我喜欢在设计视图中打开我的表单,但我制作了一个只有代码的部分类文件,Visual Studio 一直想在设计视图中打开它。为了防止 Visual Studio 意识到设计器可以加载特定的源文件,请查看 csproj 文件以获取相应源文件的 Compile Include 标记,并删除其下方的 SubType 标记。

回答by Aaron Palmer

I came across this issue myself recently and the above solutions did not solve my issue. I needed to go into Tools | Optionsand change the settings for HTML Designerto Enable HTML designerand select Start pages in: Source View.

我最近自己遇到了这个问题,上述解决方案并没有解决我的问题。我需要进入Tools | Options并更改HTML Designerto的设置Enable HTML designer并选择Start pages in: Source View.

Settings screenshot

设置截图