Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How does Visual Inheritance work in .Net?
Message
De
18/06/2007 23:27:05
 
 
À
18/06/2007 16:24:02
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:
01234155
Vues:
11
I believe you also need to use the DefaultValue attribute on the Property:
[DefaultValue(typeof(Font),"Verdana,8pt")]
public override Font Font
{
   get { return base.Font; }
   set { base.Font = value; }
}
~~Bonnie


>Hi, Calvin
>
>The reason for this, is that when you drop subclassed controls onto a form, the Winform designer will generate code in the form for some of the standard display properties (like font). So if you go back and change the subclass, it won't be reflected on the form, because the Winform designer already generated the code.
>
>I wrote an article in CoDe Magazine on this....I covered this on the fifth page...
>
>http://www.code-magazine.com/article.aspx?quickid=0703092&page=5
>
>
>Essentialy, in the subclass, you can't just simply set the font property. You have to do something a bit more elaborate...
>
>
>override public Font Font
>{
>   get { return base.Font; }
>   set { base.Font = value; }
>}
>
>public MyLabelClass()
>{
>     base.Font = new  Font("Verdana",8);
>}
>
>
>Hope that helps...
>Kevin
Bonnie Berent DeWitt
NET/C# MVP since 2003

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

Click here to load this message in the networking platform