Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2005

Tip: Looking for answers? Try searching our database.

derived usercontrol

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ferdinand Zaubzer - 15 Dec 2005 18:01 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.