scale fonts together with controls

With WinForms, I can use Control.Scale to scale a control larger. When I do that, all child controls are repositioned and scaled correctly, but font size remains the same.

Is there an easy way to force font to scale up/down, or is the only way to manually update font for all controls when control is being scaled?

Background: I'm working on a program in which I need to support zoom in/out to make labels, textboxs, etc. more readable for users with poor eyesight.

Answers


Do it the other way around. Change the font size, the controls will automatically scale to accommodate the larger font. For example:

  public partial class Form1 : Form {
    float mDesignSize;
    int mIncrement;
    public Form1() {
      InitializeComponent();
      mDesignSize = this.Font.SizeInPoints;
    }
    private void adjustFont() {
      float size = mDesignSize * (1 + mIncrement / 7f);
      this.Font = new Font(this.Font.FontFamily, size);
    }
    private void btnIncreaseFontSize_Click(object sender, EventArgs e) {
      mIncrement += 1;
      adjustFont();
    }
    private void btnDecreateFontSize_Click(object sender, EventArgs e) {
      mIncrement -= 1;
      adjustFont();
    }
  }

Need Your Help

Trouble with query declaring 2 different variables?

php mysql

I'm trying to pull results based on ONLY a state entry OR a state and city entry from POST and its driving me nuts...

PHP/HTML: Creating an element using php, with the click of a button

php html

I've been trying to do something very complicated (in my opinion, because it doesn't quite work the way I want it to). What I want, is that I have a text field where I type in something, then next to

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.