title: Swapping control position in TableLayoutPanel
body: <p>EDIT:</p>
  
  <p>Okay so for clarity I will improve my information a bit more:</p>
  
  <p>I have a TableLayoutView (I will call this tlv) that has <strong>5 fixed</strong> columns, and <strong>x + 2</strong> rows. The first row of tlv contains labels in each cell for <strong>header purposes</strong>. I dynamically add more rows onto tlv and so that it why it has a variable amount of rows (plus the initial header row which is never removed).</p>
  
  <p>As another tiny small complication, I also keep an empty row entry at the bottom of tlv which I must keep because I use it for other functionality. </p>
  
  <p>To visualise what I have just said, this is an example of tlv consisting with 4 entries (numbered), the header row (H's) and the placeholder row (P's).</p>
  
  <pre><code>HHHHH
  11111
  22222
  33333
  44444
  PPPPP
  </code></pre>
  
  <p>I want to go from that, to say, if I wanted to swap entry 2 and 3 the output would be:</p>
  
  <pre><code>HHHHH
  11111
  33333
  22222
  44444
  PPPPP
  </code></pre>
  
  <p>The code I have so far is as follows: </p>
  
  <pre><code>for (int j = 0; j &lt; 5; j++)
  {
      TableLayoutPanelCellPosition tablePosition1 = new 
      TableLayoutPanelCellPosition(j, rowIndex + 1);
      Control moveControl1 = queuedFiles.GetControlFromPosition(j, rowIndex);
      queuedFiles.SetCellPosition(moveControl1, tablePosition1);
  
      TableLayoutPanelCellPosition tablePosition2 = new 
      TableLayoutPanelCellPosition(j, rowIndex);
      Control moveControl2 = queuedFiles.GetControlFromPosition(j, rowIndex + 1);
      queuedFiles.SetCellPosition(moveControl2, tablePosition2);
  
      if (j.Equals(0))
      {
          moveControl1.Text = (rowIndex + 1).ToString();
          moveControl2.Text = (rowIndex).ToString();
      }
  }
  </code></pre>
  
  <p>However this code doesn't work and for the example above it produces:</p>
  
  <pre><code>HHHHH
  11111
  33222
  22333
  44444
  PPPPP
  </code></pre>
  
  <p>What I believe is happening is tlv is automatically organising it's contents itself during the process of moving them around (maybe to fill vacant spaces?).</p>
  
  <p><strong>rowIndex</strong> above is the index of the target row which must be swapped with the row below it. I don't need to worry about checking if there is only 1 row or if it is the last row because I have done that already. Ignore changing the text too, I just need a pointer as to how I can achieve the intended result!</p>
  
  <p>Thank you for absolutely any help you can give :)</p>