Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How does Visual Inheritance work in .Net?
Message
De
20/06/2007 21:08:49
 
 
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:
01234609
Vues:
14
Martin:

Thanks for the clarification. I'm starting to get the mantra: "If using inheritance, stay away from the designer, stay away from the designer, stay away from the designer..." Is it just me, or does this sound a bit like in some ways having been rolled back to the dBase II days and
@1,1 SAY "Get this" GET cMyVariable
, UI design -wise. Of course, if you are doing pretty much just backend stuff without UI or, as you mentioned, custom controls, this is a non-issue anyways.

Oh, well. Thank you for your insight and time, (and same goes to Kevin Goff, too.) I truly appreciate it.

Time to move on to do some production work, a little bit wiser, yet still somehow unsatisfied...


Pertti


>>Does this work with inheritance, as well? In other words, if you create a base label class with Font = Arial 8pt, then subclass it without touching the Font properties, drop your subclassed labels to a bunch of forms, then decide that Arial 8pt looks hideous and change the base label class' font to Times Roman pt 20 (beautiful!), does the message "change label fonts to Times Roman pt 20) go to all of the projects with all of the forms that use the subclassed labels, so that they, too, will look that much prettier without any additional programmer intervention?
>
>If you do: Label sample = new BigLabel();
>
>of course it works. Now the problem, again is the designer. When you drop the label the first time the stupid thing generates code like:
>
>
>this.bigLabel1 = new YourLibrary.BigLabel();
>this.bigLabel1.AutoSize = true;
>this.bigLabel1.Font = new System.Drawing.Font("Verdana", 24F);
>this.bigLabel1.Location = new System.Drawing.Point(9, 42);
>this.bigLabel1.Name = "bigLabel1";
>this.bigLabel1.Size = new System.Drawing.Size(171, 38);
>this.bigLabel1.TabIndex = 1;
>this.bigLabel1.Text = "bigLabel1";
>
>
>Of course, this means that when you change your class, your instance GETS the changes, and then is bluntly overridden by the designer code. If you ask me, yes, it is stupid. The usual workaround is the one Kevin explained here.
>
>I guess this never generated enough heat because there is a tendency in the .NET world to use Custom Controls instead of subclassing, which is something very VFP-like. Beside the historical root (C++ and VB) for this, thes is a practical reason: while in VFP you tend to package lots of stuff in an EXE, this is usually done in separate assemblies in .NET, where Custom Controls are somewhat handier.
>
>>I know this works with a lot of PEMs, I'm just curious about Fonts as an example, since they seem to be a stumbling block for the person who started this whole thread. And if it doesn't happen with Fonts, is there a list of "non-inheriting" PEMs somewheres within easy reach?
>
>Well, what the designer overrides is seen in the code it generates, which is right there, so it is easy to find out.
>
>My general approach to avoid problems with the designer is to avoid the designer. 8-) I usually cook UI stuff either on code or dinamically, if I need to do it at all. I'm more of a back-end guy...
>
>Regards,
Pertti Karjalainen
Product Manager
Northern Lights Software
Fairfax, CA USA
www.northernlightssoftware.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform