none
Font size changes RRS feed

  • Question

  • How to change the size of the lettering on my c# winform depending on how big the form is. For example if the user re sizes the form the font size should change as well.

    Debra has a question

    Tuesday, May 20, 2014 3:49 PM

Answers

  • You could handle the resize event of the Form and change the Font property of the Form in this event handler:

    public partial class Form1 : Form
    {
            public Form1()
            {
                InitializeComponent();
                this.Resize += (o, e)=>
                {
                    float fontSize = 30;
                    this.Font = new Font(this.Font.FontFamily, fontSize);
                };
     }
    }

    Of course, you have to decide on which size you want to set the font to yourself. There is no "automatic" way of deciding what the size should be based on the size of the window.

    Tuesday, May 20, 2014 8:47 PM