문제

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.

도움이 되었습니까?

해결책

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();
}

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top