Question

Is it possible to keep a control (Panel) always over all other controls even if they also use Control.BringToFront()?

I tired to use BringToFront itself, but it seems that this loose its effectiveness if another control under this control also uses this command.

Was it helpful?

Solution

It would help if you try to explain what are you trying to achieve. We might be then able to better convince you, that you are doing something very wrong :)

Anyway, no matter what trick you do, the other control may use the same trick to override you.

You can get step ahead for example by handling parent control's Layout event to force your control back to front. The Layout event is trigerred (among other) when child controls' Z-order is changed.

private void Form1_Layout(object sender, LayoutEventArgs e)
{
    panel1.BringToFront();
}

OTHER TIPS

A dirty way of dealing with this is setting a timer and everytime it ticks use the .BringToFront() method on the control, you can also add multiple controls you wish to perform this on and can arrange them however you like.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top