Visual Studio: Make view code default using attrib

2019-02-24 10:24发布

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.

3条回答
戒情不戒烟
2楼-- · 2019-02-24 10:58

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.
查看更多
爷的心禁止访问
3楼-- · 2019-02-24 11:05

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
查看更多
Animai°情兽
4楼-- · 2019-02-24 11:13

The magic line you seek is:

[System.ComponentModel.DesignerCategory("Code")]

Just put that before your control-derived type and kiss that useless designer goodbye.

查看更多
登录 后发表回答