ShapeContainer not Staying In Front of PictureBoxes

441 views Asked by At

I have a GUI in Visual Studio 2010 that has several PictureBoxes, LineShapes/Rectangles, and Labels/TextBoxes. The LineShapes/Rectangles need to be in front of the PictureBoxes, and the Labels/TextBoxes need to be in front of the LineShapes/Rectangles.

For months my GUI was working correctly, when I called the BringToFront() method in the desired order in my form's Load event handler. I first called the ShapeContainer's BringToFront() method, and I then called the BringToFront() method for all of the Labels/TextBoxes.

All of a sudden, my PictureBoxes started to show up in front of my LineShapes/Rectangles. Comparing my latest code to my last working tag shows that nothing changed with respect to these objects. I tried calling the SendToBack() method for the PictureBoxes in my form's Load event handler, but it had no effect.

Can someone explain why this behavior spontaneously changed on me, and what I should be doing to ensure the correct display of my PictureBoxes, LineShapes/Rectangles, and Labels/TextBoxes?

1

There are 1 answers

0
BigBobby On BEST ANSWER

If I call all of my PictureBoxes SendToBack methods in my Form's Paint event handler, I seem to get my desired behavior again.

Oddly, I can't call the BringToFront methods for all of my other objects there, or my LineShapes/Rectangles all disappear :/

For now this solved my problem, but I hope that the behavior doesn't change again.