views:

44

answers:

2

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!)

+2  A: 

Call the GetChildIndex and SetChildIndex methods of the parent's Controls collection.

SLaks
Great - Led astray by BringToFront() I looked in the wrong place for these methods: at the control's methods, not the parent's controls' methods. Thanks.
gt
A: 

There is no Z-order as there was in VB, but you can use the SetChildIndex method to alter thei index. Here theres an example of how to use it. You will probably need to keep a record of each controls index though so you can set it back to it when it's finished with.

w69rdy