Visual Studio: Make view code default using attribute

后端 未结 3 404
醉酒成梦
醉酒成梦 2021-01-18 16:18

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 decor

相关标签:
3条回答
  • 2021-01-18 16:42

    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
    0 讨论(0)
  • 2021-01-18 17:02

    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.
    0 讨论(0)
  • 2021-01-18 17:03

    The magic line you seek is:

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

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

    0 讨论(0)
提交回复
热议问题