Visual Studio: Make default view code using attribute

I know how to configure VS 2008 to open Windows stationery controls in code instead of a designer . But I think that I saw a way in which I could do this, with an attribute with which I could decorate the necessary controls. Does anyone know his name? This is especially useful if you want some controls to be open in the designer, and some as C # code.

+3
source share
3 answers

I think I found that you have already seen this: Brian Ensink Blog . You can use the DesignerCategory attribute to mark the class to choose how to open them:

  • If you inherit a class from System.Windows.Form, it will be opened according to the constructor.
  • If you add the [System.ComponentModel.DesignerCategory ("")] attribute, it will be opened as code.
+6
source

The magic line you are looking for:

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

Just put it in front of your manageable derived type and kiss this useless designer goodbye.

+6
source

Visual Studio 2010

  • >
  • check all settings
  • html Designer 4 select "View Source"
  • restart visual studio
-1
source

Source: https://habr.com/ru/post/1723765/


All Articles