How to set Z-order of a Control using WinForms
c#, focus, textbox, winforms, z-order
Solution
Call the `GetChildIndex` and `SetChildIndex` methods of the parent's `Controls` collection.
Problem
I'm writing a custom `TextBox` that upon gaining focus changes its border style. As adding a border causes the control to overlap with those neighbouring it, I temporarily bring the text box to the front of the dialog (using `textBox.BringToFront()`). However, once editing is complete and focus is lost, I would like to send the control back to its original position in the Z-order. Is this possible (preferably in a simple way!)