Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep Control always on top

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.

like image 865
BudBrot Avatar asked Oct 30 '25 20:10

BudBrot


1 Answers

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();
}
like image 114
Martin Prikryl Avatar answered Nov 02 '25 11:11

Martin Prikryl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!