title: TableLayoutPanel changing it's sizing
body: <p>I have a few <code>tablelayoutpanels</code> in my program in order to lay out different controls in rows. Until recently these were all working correctly, but after a change in server this is no longer the case. A potential cause is a change in screen resolution as I noticed similar problems on other computers running my program.</p>
  
  <p>An example of this problem is shown below</p>
  
  <p><img src="https://i.stack.imgur.com/jTGhs.png" alt="enter image description here"></p>
  
  <p>Before the data rows are loaded (from database), the sizing is incorrect. A measurement using the VS designer shows that the size in figure 2 is correct. Interestingly, if I add a blank row to this table then the resizing doesn't happen.</p>
  
  <pre><code>public JobOpMainTable()
  {
      DoubleBuffered = true;
      AutoSize = true;
      AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
      DoubleBuffered = true;
      BackColor = Color.White;
      CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
      headers();
  }
  
  private void headers()
  {
      string[] names = { "Operation", "Est Lab Hrs", "Est UM Hrs", "Act Lab Hrs", "Act UM Hrs" };
      for (int i = 0; i &lt; names.Length; i++) header(names[i], i);
  }
  
  private void header(string name, int col)
  {
      Panel pan = new Panel();
      pan.Width = widths[col];
      pan.Height = 25;
      pan.BackColor = Color.Black;
      pan.Dock = DockStyle.Fill;
      pan.Margin = new System.Windows.Forms.Padding(0);
      TextBox txt = new TextBox();
      txt.Font = new System.Drawing.Font("Microsoft sans serif", 8, FontStyle.Bold);
      txt.Text = name;
      txt.ReadOnly = true;
      txt.BackColor = Color.Black;
      txt.ForeColor = Color.White;
      txt.Dock = DockStyle.Fill;
      txt.BorderStyle = System.Windows.Forms.BorderStyle.None
      pan.Controls.Add(txt);
      Controls.Add(pan, col, 0);
  }
  
  private int newRow()
  {
      int row = Controls.Count / 5;
      for (int i = 0; i &lt;= 4; i++)
      {
          TextBox txt = new TextBox();
          txt.Width = widths[i];
          txt.BackColor = Color.White;
          txt.BorderStyle = System.Windows.Forms.BorderStyle.None;
          txt.ReadOnly = true;
          txt.Dock = DockStyle.Fill;
          txt.Margin = new Padding(0);
          txt.Enter += new EventHandler(enterCell);
          txt.Leave += new EventHandler(leaveCell);
          Controls.Add(txt, i, row);
      }
      return row;
  }
  </code></pre>
  
  <p>Above is the code I believe is relevant to the problem. The resizing occurs the first time <code>newRow()</code> is called when loading in data: each new box makes the column wider. Again though, the odd thing is this doesn't occur if I add a row from the constructor</p>