Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 designer, that won't stop the subclasses from being edited in the designer?

like image 885
Simon Avatar asked Oct 23 '08 15:10

Simon


1 Answers

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.

like image 63
Philip Rieck Avatar answered Nov 07 '22 14:11

Philip Rieck