Visual Studio:使用属性使视图代码默认

发布于 2024-08-12 05:54:16 字数 206 浏览 9 评论 0原文

我知道如何配置 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浪菊怪哟 2024-08-19 05:54:16

您寻求的神奇路线是:

[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.

温柔嚣张 2024-08-19 05:54:16

我想我已经找到了您已经看到的地方: 布莱恩·恩辛克的博客。您可以使用 DesignerCategory 属性按顺序标记类选择它们的打开方式:

  • 如果您从System.Windows.Form继承一个类,它将由设计器视图打开。
  • 如果添加 [System.ComponentModel.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:

  • If you inherit a class from System.Windows.Form, it will be open by the designer view.
  • If you add the [System.ComponentModel.DesignerCategory("")] attribute, it will be open by the code view.
那一片橙海, 2024-08-19 05:54:16

中可用

  1. 此选项在 Visual Studio 2010工具 > 。选项
  2. 检查显示所有设置
  3. html 设计器
    4.选择Source View
  4. 重启Visual Studio

This option is available in Visual studio 2010

  1. Tools > Options
  2. check show all settings
  3. html Designer
    4 select Source View
  4. restart Visual Studio
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文