title: Why doesn't my TableLayoutPanel use all of its size when divided by percentages?
body: <p>I am dynamically adding controls to a TableLayoutPanel.</p>
  
  <p>It has 12 rows and 32 columns.</p>
  
  <p>I've divided the widths of the columns so that those with labels are twice as wide 
  as those with TextBoxes, and the percentages add up to 100:</p>
  
  <pre><code>labels = 5%
  textBoxes = 2.5%
  </code></pre>
  
  <p>As there are 24 textboxes per row and 8 labels per row, this equals 100% (40% labels, 60% textBoxes).</p>
  
  <p>HOWEVER, the last column is a spacehog, as can be seen here:</p>
  
  <p><a href="http://warbler.posterous.com/the-32-column-is-wider-than-the-rest" rel="nofollow">http://warbler.posterous.com/the-32-column-is-wider-than-the-rest</a></p>
  
  <p>And I need that space for the labels to show their entire selves: they are really five characters wide ("00:00" ... "23:45") not four, as displayed.</p>
  
  <p>Based on empirical evidence (previous trial-and-error) I could reduce the width of the TLP to skinny up that last column, but that doesn't solve my label-cells-too-skinny problem.</p>
  
  <p>This is how I'm slapping the controls on the TLP (I've set the column width percentages at design-time, via the properties page for Columns collection)</p>
  
  <pre><code>private void AddPlatypusScheduleControlsToTableLayoutPanel()
  {
      try
      {
          this.SuspendLayout();
          tableLayoutPanelPlatypusSchedule.ColumnCount = PLATYPUS_SCHEDULE_COL_COUNT;
          int ColNum = 0;
          int RowNum = 0;
          int LoopCounter = 1;
          var dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
  
          while (LoopCounter &lt;= QUARTER_HOUR_COUNT)
          {
              string lblName = string.Format("labelPS{0}", LoopCounter);
              var lbl = new Label
                  {
                      Name = lblName,
                      Dock = DockStyle.Fill,
                      Margin = new Padding(),
                      Font = new Font("Microsoft Sans Serif", 7),
                      TextAlign = ContentAlignment.MiddleCenter,
                      Text = dt.ToString("HH:mm")
                  };
              tableLayoutPanelPlatypusSchedule.Controls.Add(lbl, ColNum, RowNum);
  
              string txtbxName1 = string.Format("textBoxLSA{0}", LoopCounter);
              var txtbxa = new TextBox { Name = txtbxName1, Dock = DockStyle.Fill, Margin = new Padding() };
              string txtbxName2 = string.Format("textBoxLSB{0}", LoopCounter);
              var txtbxb = new TextBox { Name = txtbxName2, Dock = DockStyle.Fill, Margin = new Padding() };
              string txtbxName3 = string.Format("textBoxLSC{0}", LoopCounter);
              var txtbxc = new TextBox { Name = txtbxName3, Dock = DockStyle.Fill, Margin = new Padding() };
              tableLayoutPanelPlatypusSchedule.Controls.Add(txtbxa, ColNum + 1, RowNum);
              tableLayoutPanelPlatypusSchedule.Controls.Add(txtbxb, ColNum + 2, RowNum);
              tableLayoutPanelPlatypusSchedule.Controls.Add(txtbxc, ColNum + 3, RowNum);
  
              dt = dt.AddMinutes(15);
              RowNum++;
              LoopCounter++;
              if (RowNum == 12)
              {
                  ColNum = ColNum + 4;
                  RowNum = 0;
              }
          }
      }
      finally {
          this.ResumeLayout();
      }
  }
  </code></pre>
  
  <h2>UPDATE</h2>
  
  <p>I thought maybe the problem was the width of the TLP was not exactly divisible by 32 (it was 619); so I widened it to 640, yet the same problem remains.</p>
  
  <h2>UPDATE 2</h2>
  
  <p>To get it to work, I had to use absolute sizes for the columns rather than percentages*, and increase the width of the label-holding columns to 35 (which leaves only 15 for the textBox-holding columns at a TLP width of 640).</p>
  
  <ul>
  <li>WPF can be a bear at times (more like a Kodiak than Winnie), but it sure fills the bill for situations like this, where I worry about absolute sizes going all to Dallas on different resolutions/screen sizes, etc.</li>
  </ul>