title: C#: How to swap the position of two winform controls
body: <p>Let's say you have two <code>Control</code>s, Alice and Bob, and you want to swap their position. By that I mean that after the swap:</p>
  
  <ul>
  <li>If they are living in the same <code>ControlCollection</code>, Alice should have the index of Bob and vice versa.</li>
  <li>If in different <code>ControlCollection</code>s, Alice should have the same index as Bob, but be in Bobs <code>ControlCollection</code> and vice versa.</li>
  </ul>
  
  <p>How would you do this? I am a bit unsure how to best solve this because of how the <code>ControlCollection</code> methods work. For example using the <code>Remove</code> method to remove a control will change the index of all the controls coming after it in the collection. The SetChildIndex works in a similar way.</p>
  
  <p><strong><em>Edit:</strong> The parent controls of Alice and Bob are flow layout panels. This is why I want to swap their index which will in effect swap their position in the flow layout panel.</em></p>