views:

217

answers:

1

I have a base class for all my textboxes and I want to set the default font in that class. So I started with this:

  public partial class MyTextBox : TextBox
  {
    public WmlTextBox()
    {
      InitializeComponent();
      //Font for the whole application can be altered in the Appearance class
      Font = new Appearance().TextBoxFont;
    }
  }

I then stripped out all the code in the form that was setting the font of the textboxes. Of course this worked fine until I altered an item on the page. Visual Studio picked up the default font for the application (set in the Appearance class), and generated code in the designer for all TextBoxes to set it to that specific font. How can I stop visual studio from generating code from my default font? I want to allow the developers to change the property, but I want to set the default font centrally.

+1  A: 

override/new the Font property, and apply the DesignerSerializationVisibility attribute with the Hidden option.

leppie
Superb! Thank-you for such a prompt answer. That nailed It.
Colin
It's annoying when you forget to do that though :)
leppie