Search code examples
c#winformsuser-controlstopmost

Drawing Custom Control above all other controls (previously added)


I have a UserControl that adds other UserControls, but I want the "latest" control added to be topmost so it's above the others. Because the controls should be overlapping eachother. Like a card game. So I add 5 controls, the first one should have the least priority the latest the most priority - most visible.

Any ideas?

Or do I have to override the Paint method for the "container" control? And Control.CreateGraphics() and draw it?


Solution

  • Consider BringToFront and SendToBack methods of the Control class. Check out answers to these questions too

    How to set Z-order of a Control using WinForms

    Bring Winforms control to front