Is there an attribute I can add to a class so it will be edited as code, not in the designer?

前端 未结 1 622
甜味超标
甜味超标 2020-12-30 04:09

I\'ve made a class which inherits from UserControl, but which I only want to use as a base for subclasses. Is there a way I can stop VS2008 from trying to edit it in the de

相关标签:
1条回答
  • 2020-12-30 04:49

    There is. I believe if you have multiple classes in a file, VS looks at the first one only, but I may be mistaken. In any case, this should do the trick:

    [System.ComponentModel.DesignerCategory("Code")]
    public class SomeBaseClass : UserControl
    {
     //...
    }
    

    Note that in versions of Visual Studio prior to 2017, you must use the full name of the attribute as shown above. If you try putting a using statement above it and simply trying "DesignerCategory" visual studio may not honor it.

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