Visual Studio:使用属性使视图代码默认
我知道如何配置 VS 2008 以在代码而不是设计器中打开 Windows 窗体控件。但我想我已经找到了一种方法,可以使用一个可以装饰所需控件的属性来实现此目的。有谁知道它的名字吗?如果您希望在设计器中打开一些控件并在 C# 代码视图中打开一些控件,这尤其有用。
I know how to configure VS 2008 to open windows forms controls in code instead of the designer. But I think I have seen a way I could do this with an attribute I could decorate the desired controls with. Does anyone know its name? This is especailly usefull if you want some controls to be opened in the designer and some in the c# code view.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您寻求的神奇路线是:
[System.ComponentModel.DesignerCategory("Code")]
只需将其放在控件派生类型之前,然后与无用的设计器吻别。
The magic line you seek is:
[System.ComponentModel.DesignerCategory("Code")]
Just put that before your control-derived type and kiss that useless designer goodbye.
我想我已经找到了您已经看到的地方: 布莱恩·恩辛克的博客。您可以使用 DesignerCategory 属性按顺序标记类选择它们的打开方式:
I think I have found where you already seen that: the Brian Ensink's blog. You can use the DesignerCategory attribute to mark class in order to choose how they are opened:
中可用
4.选择Source View
This option is available in Visual studio 2010
4 select Source View