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?
views:
144answers:
1
+12
A:
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
{
//...
}
Please note that 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.
Philip Rieck
2008-10-23 15:26:03
The base class now opens as code, but the derived classes *also* do. But if you add a dummy class above with that attribute, it works a charm!
Simon
2008-10-23 15:56:49