I'm trying to reverse the order of Controls in a FlowLayoutPanel.
I tried converting the ControlCollection to an array and then reversed that and cleared the ControlCollection and then readded the Controls. But this doesn't seem to have the planned effect.
Here's the code I use:
private static void ReverseLayout(Control control, bool suspend = true) {
if (suspend) control.SuspendLayout();
Control[] newCC = new Control[control.Controls.Count];
control.Controls.CopyTo(newCC, 0);
Array.Reverse(newCC);
control.Controls.Clear();
//control.Controls.AddRange(newCC);
for (int i = 0; i < newCC.Length; i++) {
newCC[i].Location = new System.Drawing.Point(); // maybe? no :\
newCC[i].TabIndex = i; // maybe? no :\
control.Controls.Add(newCC[i]);
}
if (suspend) control.ResumeLayout(false);
}