Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9124237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:31:39+00:00 2026-06-17T06:31:39+00:00

I am using a TableLayoutPanel to contain controls that I would like to have

  • 0

I am using a TableLayoutPanel to contain controls that I would like to have automatically resize when the form is resized. I would like to know how to make a form’s child controls “scale” in size proportional to the form when the form itself is resized? Although the TableLayoutPanel automatically adjusts the sizes of the contained controls, those controls keep the same font size.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:31:40+00:00Added an answer on June 17, 2026 at 6:31 am

    This is the best method I have come up with so far. I use two scale factors and I iterate through all the controls to selectively choose which ones I want to scale:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace TestTableLayoutPanel
    {
        public partial class Form2 : Form
        {
            private const float LARGER_FONT_FACTOR = 1.5f;
            private const float SMALLER_FONT_FACTOR = 0.8f;
    
            private int _lastFormSize;
    
            public Form2()
            {
                InitializeComponent();
    
                this.Resize += new EventHandler(Form2_Resize);
                _lastFormSize = GetFormArea(this.Size);
            }
    
            private int GetFormArea(Size size)
            {
                return size.Height * size.Width;
            }
    
            private void Form2_Resize(object sender, EventArgs e)
            {
    
                var bigger = GetFormArea(this.Size) > _lastFormSize;
                float scaleFactor = bigger ? LARGER_FONT_FACTOR : SMALLER_FONT_FACTOR;
    
                ResizeFont(this.Controls, scaleFactor);
    
                _lastFormSize = GetFormArea(this.Size);
    
            }
    
            private void ResizeFont(Control.ControlCollection coll, float scaleFactor)
            {
                foreach (Control c in coll)
                {
                    if (c.HasChildren)
                    {
                        ResizeFont(c.Controls, scaleFactor);
                    }
                    else
                    {
                        //if (c.GetType().ToString() == "System.Windows.Form.Label")
                        if (true)
                        {
                            // scale font
                            c.Font = new Font(c.Font.FontFamily.Name, c.Font.Size * scaleFactor);
                        }
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TableLayoutPanel that contains rows of labels. This control lives on form
This is really simple. I have a TableLayoutPanel that is populated with controls (just
I generate controls for a TableLayoutPanel dynamically. I have a delete button in each
I'm using visual studio 2008 I have a control that dispays a processed image.
I have a TableLayoutPanel control that is initially empty - 0 rows and 0
Using SSRS 2008 R2 I have a background process that dynamically generates RDL for
I have a user control that contains a 2-column TableLayoutPanel and accepts commands to
When using the System.Windows.Forms.TableLayoutPanel control on a windows form, it sets the background color
I started with using a TableLayoutPanel, but when I have big tables, they are
I'd like to implement a custom TabLayoutPanel which would automatically setup the tab itself

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.