I have 2 pictureBoxes on a flowLayout Panel and need move the pictureBox1 to pictureBox2's position and pictureBox2 to pictureBox1's position
EDIT:
I have tried but the pictureBoxes dont move...I have used MessageBox for check the positions..and the positions are right but they dont swap the position(the locations not changed...)
MessageBox.Show("PixBoxMover x " + picBoxMover.Location.X + "y " + picBoxMover.Location.Y);
MessageBox.Show("picBoxMovendo x " + picBox.Location.X + "y " + picBox.Location.Y);
Point temp = picBox.Location;
picBox.Location = picBoxMover.Location;
picBoxMover.Location = temp;
MessageBox.Show("PixBoxMover x " + picBoxMover.Location.X + "y " + picBoxMover.Location.Y);
MessageBox.Show("picBoxMovendo x " + picBox.Location.X + "y " + picBox.Location.Y);
You can change the ordering by setting the index of the child control (pictureBox) within the container control (flowLayoutPanel):
var index1 = flowLayoutPanel1.Controls.IndexOf(pictureBox1);
var index2 = flowLayoutPanel1.Controls.IndexOf(pictureBox2);
flowLayoutPanel1.Controls.SetChildIndex(pictureBox1, index2);
flowLayoutPanel1.Controls.SetChildIndex(pictureBox2, index1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With