I have a custom user control and have overridden its Font property.
When I drop a copy of my usercontrol onto a form, I can set the Font property just fine, but I don’t see the value I set for ‘Font’ showing up in my form’s designer file. When I compile/run my app, the value I entered is lost.
Note that I also want to override the Text property and couldn’t see the set value for this in the designer file either — until I found an answer on here to help do that (I needed to set the the ‘DesignerSerializationVisibility’ and ‘EditorBrowsable’ attributes). I’ve tried doing the same for Font but to no avail. Any ideas?
private Font _Font = UserControl.DefaultFont;
[Description("Sets the font of the button caption"),,
Browsable(true),
Bindable(true),
EditorBrowsable(EditorBrowsableState.Always),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override Font Font
{
get { return _Font; }
set
{
_Font = value;
}
}
Change your code to this: