title: Resizing rows in TableLayoutPanel
body: <p>Simply put, I am trying to add labels dynamically into a TableLayoutPanel that can be invisible and, in that case, setting the height to 0 to avoid awkward empty rows.</p>
  
  <p>(I need this to work like an accordion, and I am using a TableLayout because later I will need to use complex controls such as treeViews):</p>
  
  <pre><code>while index &lt; myDataTable.rows.count
      dim myLabel as new Label
      myLabel.Name = myDataTable.rows(index)("labelText").toString
      myLabel.Text = myDataTable.rows(index)("labelText").toString
  
      myTableLayout.controls.Add(myLabel, 0, index)
  
      If cbool(row("initialyVisible")) then
          myTableLayout.GetControlFromPosition(0, index).Visible = true
          myTableLayout.RowStyles.Add(New RowStyle(SizeType.Absolute, 150))
      else
          myTableLayout.GetControlFromPosition(0, index).Visible = false
          myTableLayout.RowStyles.Add(New RowStyle(SizeType.Absolute, 0))
      endif
      index = index + 1
  end while
  </code></pre>
  
  <p>This works well.</p>
  
  <p>However, during the execution, the visible status of these labels + rows height might change:</p>
  
  <pre><code>If visibleFlag = true Then
     myTableLayout.RowStyles(i).Height = 150
     myTableLayout.GetControlFromPosition(0, i).Visible = True
  Else
     myTableLayout.RowStyles(i).Height = 0
     myTableLayout.GetControlFromPosition(0, i).Visible = false
  End If
  </code></pre>
  
  <p>Causing the 2 problems illustrated
  <a href="http://i.stack.imgur.com/ayPQe.png" rel="nofollow">in this image</a>.
  Anything that can be done?</p>