开发者

How to prevent Visual Studio setting my default font sizes in an inherited control

开发者 https://www.devze.com 2022-12-24 08:38 出处:网络
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:

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 Appea开发者_开发技巧rance().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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消