Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Abstract UserControl
Message
De
01/09/2007 01:22:40
 
 
À
28/08/2007 13:37:14
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01250968
Message ID:
01251855
Vues:
13
Viv,

I don't know if it's the best way around your problem, but you seemed to have found a decent trick.

I had need of an abstract class a while ago and could think of no easy way to implement it because, like you, it was a UserControl that needed to have visually designable sub-classes.

Since this was one of my "Framework" classes, and all our developers know that they have to sub-class the Framework classes and cannot use them directly, that particular reason for using an abstract class was not an issue. My only reason for needing an abstract class was because I needed to have abstract methods.

My workaround was to not make it abstract. And all the methods that would normally have been abstract methods I simply made them virtual (obviously) and put a MessageBox.Show("Developer must override method Such-and-Such"); with appropriate (and sometimes lengthy) /// comments explaining what needed to be put into the method.

~~Bonnie




>Hi,
>
>I have an abstract class derived from System.Windows.Forms.UserControl with further classes derived from this. All fine except that, obviously, immediate child classes cannot be instantiated at design time thus making it difficult to modify the contained controls visually.
>
>I'm currently working around this by changing the child class to temporarily derive directly from UserControl, doing the design mods, then reverting to deriving from the abstract class. Anyone know of any 'trick' to make this a bit easier (I can't insert a dummy class between the final class and the abstract because I'd be forced to implement the abstract methods there which would defeat the object [no pun intended]....)
>
>Regards,
>Viv
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform