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 8480919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:25:32+00:00 2026-06-10T19:25:32+00:00

In my TableLayoutPanel, I’m dynamically adding twelve rows (and several columns). When I had

  • 0

In my TableLayoutPanel, I’m dynamically adding twelve rows (and several columns). When I had the TableLayoutPanel’s Rows collection set to Autosize, the 12th row would be generated, but would not display. I changed it to Percentage, with each row getting 8.33% (I actually set it to 8, and it was automatically changed to 8.33).

So that should be perfect to the naked eye (99.99999999%), but now the twelfth row has more space than the others, and the 16th column the same, so the TableLayoutPanel has “dead space” at the bottom and right, and the labels I have in the final row are not aligned with the textBoxes I have in the neighboring column.

In case anybody’s interested in seeing the actual code:

private void AddControlsToPlatypusTableLayoutPanel()
{
    string lblName;
    string txtbxName;
    int ColNum = 0;
    int RowNum = 0;
    int LoopCounter = 1;
    DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);

    while (LoopCounter <= 96) {
        // Create the Label
        lblName = string.Format("label{0}", LoopCounter);
        var lbl = new Label() {
            Name = lblName,
            Dock = DockStyle.Fill,
            Margin = new Padding(),
            TextAlign = ContentAlignment.MiddleCenter,
            Text = dt.ToString("HH:mm")
        };
        tableLayoutPanelPlatypus.Controls.Add(lbl, ColNum, RowNum);

        // Create the TextBox
        txtbxName = string.Format("textBox{0}", LoopCounter);
        var txtbx = new TextBox() {
            Name = txtbxName, Dock = DockStyle.Fill, Margin = new Padding()
        };
        tableLayoutPanelPlatypus.Controls.Add(txtbx, ColNum + 1, RowNum);

        dt = dt.AddMinutes(15);
        RowNum++;
        LoopCounter++;
        // Move over if at the bottom
        if (RowNum == 12) { 
            ColNum = ColNum + 2;
            RowNum = 0;
        }
    }
}

UPDATE

By tweaking the Size and Location a smidgin, I can get it all to look good, but now I either have to live with a cushion around it or change the size of the form and all the other controls, or many of them, anyway. So I still consider it a bit irregular that the percentages didn’t work out as one would expect them to. I know, I know: WPF. But that’s not an option at present.

  • 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-10T19:25:34+00:00Added an answer on June 10, 2026 at 7:25 pm

    if you have set it to 8 then 8*12 conclude to 84% with 16% remaining which will be accommodated in last row as well same case applies to last column. So you need to define it to 100/12 = 8.33%. if you made each row with 8.33% and last row with 8.37% this will look nice. you need to complete 100% in both case of rows or columns. or you can use fix size instead. if you want variable size of table then be sure you do not define size of table and rows height and columns width define table size dynamically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an autoscrolling TableLayoutPanel to which I am dynamically adding rows. I would
I have a TableLayoutPanel to which I add rows dynamically. Each row has an
I am dynamically adding controls to a TableLayoutPanel. It has 12 rows and 32
I'm attempting to dynamically add both columns and rows to a TableLayoutPanel. I have
I have a tablelayoutpanel. 2x2 - 2 columns 2 rows. For example, I added
In TableLayoutPanel if we set AutoSize = true and Dock = fill then last
I have a TableLayoutPanel with 3 columns and 1 row: (Remove button, User Control,
Stack-O, I have a TableLayoutPanel with 50 rows and 6 columns. That's all well
I have added controls dynamically on runtime inside the rows of a tableLayoutpanel ,
I am using a tableLayoutPanel which consist of two rows. In first row I

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.