Is there any possibility to create a usercontrol deriving from an
abstract usercontrol?
I could only achieve it by editing the code from "MyControl :
System.Windows.Forms.UserControl" to "MyControl : MyAbstractControl" by
hand.
MyAbstractControl is declared abstract and it is derived from
System.Windows.Forms.UserControl.
If I do that, the controls cannot be displayed anymore in the designer.
What can I do to get around this problem
Thanks
Ferdinand
Kevin Spencer - 15 Dec 2005 18:32 GMT
Hi Ferdinand,
You will need to create a custom Designer for your Control.

Signature
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
> Is there any possibility to create a usercontrol deriving from an abstract
> usercontrol?
[quoted text clipped - 9 lines]
> Thanks
> Ferdinand
Bruce Wood - 15 Dec 2005 18:49 GMT
In order to design your derived control, the Designer must first create
an instance of the base control class at design time. Since you've
declared the base abstract, it can't do that, so it can't provide you
with a design surface to work on.
So, no, you can't design controls derived from abstract classes.
The closest you can come is to test the DesignMode property in your
base calss (after your constructor... typically in your OnLoad method
or something like that) and, if it's false, throw an
InvalidOperationException. That way you know that your base class will
never be instantiated at run time.