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

.net, c#, visual-studio-2008

Solution

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.

Problem

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?

Original source