Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How does Visual Inheritance work in .Net?
Message
De
19/06/2007 01:32:59
 
 
À
18/06/2007 23:27:05
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Divers
Thread ID:
01234107
Message ID:
01234166
Vues:
11
I believe you also need to use the DefaultValue attribute on the Property:

Hey, Bonnie,

Obviously, you and I talked about this offline a little while ago. I agree that it's best to use the DefaultValue attribute, but I was a little surprised to see the behavior even if I didn't use it (and just relied on a statement in the constructor).

If I have a label subclass with a foreground color of Red (set in the constructor, but no defaultvalue), drop the label on the form, change it to Green, run it, then decide that green looks horrible.....if I do a RESET on the forecolor property in the designer, it changes it to the system default (black). However, if I either run the form, or close the form and reopen in the designer, I'll see the color from my subclass (red).

Similar deal with a font name property..if my subclass has Arial....and then I override and select Verdana, and then reset....the immediate visual display is the system default (sans Serif). But if i run it, or close and reopen, I see Arial.

Anyway, not debating, I agree, DefaultValue should be used...but unless I'm missing something, the only thing it appears to do is give immediate feedback if you reset. (Not minimizing that, it's important, and I'm guessing there might be other benefits we haven't touched on)

Good discussion...
Kevin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform