Visual Studio: Make view code default using attribute

和自甴很熟 提交于 2019-12-01 18:05:56

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.

The magic line you seek is:

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

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

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!