问题描述
我知道如何配置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.
推荐答案
我想我已经找到您已经看到的地方: Brian Ensink的博客.您可以使用 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:
- 如果您从System.Windows.Form继承一个类,则设计器视图将打开它.
- 如果添加[System.ComponentModel.DesignerCategory(")]属性,它将在代码视图中打开.
这篇关于Visual Studio:使用属性将视图代码设为默认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!