K
Kevin
This problem has stumped me for almost two years now. In a nutshell...
1) I create a textbox class, and set the font to Tahoma 8
2) I drop the textbox class on a form, and set other properties (name, etc.)
3) I build my form, and then users say they don't want Tahoma 8, they want
Tahoma 9
4) I go back to the textbox class and change it to Tahoma 9
5) I return to the form and rebuild it, and it still shows Tahoma 8 when I
run it.
Only way to get it to show Tahoma 9 is to right-click on font in the prop
sheet, and click RESET...very inefficient if there are many forms.
I realized the reason for the behavior is that in step 2, the Winform
designer actually writes code out based what the font evaluates to at that
time. So that basically 'breaks' inheritance. Coming from VFP world, where
inheritance seems to be 'clean', this was a real shock.
I recently came across localizable, ambientvalue, and shouldserialize, and
thought those would help...but they don't seem to have any effect (at least
not the way I'm using them).
So basically, here's a stripped down version of my textbox class...
public class ccTextBox : System.Windows.Forms.TextBox
{
private Font _MyFont;
public Font MyFont
{
get { return _MyFont;}
set { _MyFont = value;}
}
public ccTextBox()
{
MyFont = new Font("Tahoma",8);
this.Font = MyFont;
}
}
How would/where would I set localizable (and maybe ambientvalue) so that my
winform will always read from the class, and never generate code in the
designer? I tried the following right above where I created the font
property, but to no avail...
[ Localizable(true), AmbientValue(null) ]
I'll be SO grateful to whomever can help me on this one!
Thanks,
Kevin
1) I create a textbox class, and set the font to Tahoma 8
2) I drop the textbox class on a form, and set other properties (name, etc.)
3) I build my form, and then users say they don't want Tahoma 8, they want
Tahoma 9
4) I go back to the textbox class and change it to Tahoma 9
5) I return to the form and rebuild it, and it still shows Tahoma 8 when I
run it.
Only way to get it to show Tahoma 9 is to right-click on font in the prop
sheet, and click RESET...very inefficient if there are many forms.
I realized the reason for the behavior is that in step 2, the Winform
designer actually writes code out based what the font evaluates to at that
time. So that basically 'breaks' inheritance. Coming from VFP world, where
inheritance seems to be 'clean', this was a real shock.
I recently came across localizable, ambientvalue, and shouldserialize, and
thought those would help...but they don't seem to have any effect (at least
not the way I'm using them).
So basically, here's a stripped down version of my textbox class...
public class ccTextBox : System.Windows.Forms.TextBox
{
private Font _MyFont;
public Font MyFont
{
get { return _MyFont;}
set { _MyFont = value;}
}
public ccTextBox()
{
MyFont = new Font("Tahoma",8);
this.Font = MyFont;
}
}
How would/where would I set localizable (and maybe ambientvalue) so that my
winform will always read from the class, and never generate code in the
designer? I tried the following right above where I created the font
property, but to no avail...
[ Localizable(true), AmbientValue(null) ]
I'll be SO grateful to whomever can help me on this one!
Thanks,
Kevin