471,605 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 software developers and data experts.

derived usercontrol

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
Dec 15 '05 #1
2 1588
Hi Ferdinand,

You will need to create a custom Designer for your Control.

--
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.

"Ferdinand Zaubzer" <fe***************@schendl.at> wrote in message
news:eQ*************@TK2MSFTNGP15.phx.gbl...
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

Dec 15 '05 #2
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.

Dec 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Dennis | last post: by
reply views Thread by --== Alain ==-- | last post: by
reply views Thread by MichaelMortimer | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.