简体   繁体   English

C#最顶层的窗口

[英]C# topmost window

I have two windows form and both set the topmost property to true. 我有两个窗体,并将最顶层的属性设置为true。 But the form border style of the one form is Set to "None". 但是一种形式的表单边框样式设置为“无”。 The other form has border. 另一种形式有边界。 When these two forms launch together, the one without the border is always on top and overlap the other form. 当这两个形式一起发射时,没有边框的那个总是在顶部并与另一个形式重叠。 How do i make the form with border always on top? 如何使带边框的表单始终位于顶部? thanks. 谢谢。

I suggest you to start the form with borders last or set other form TopMost property to false. 我建议你最后用border开始表单,或者将其他表单TopMost属性设置为false。

[Edit] I sugest you to look at the Forms Owner property - http://msdn.microsoft.com/en-us/library/system.windows.forms.form.owner.aspx . [编辑]我想你看一下Forms Owner属性 - http://msdn.microsoft.com/en-us/library/system.windows.forms.form.owner.aspx

formWithoutBorders.AddOwnedForm(borderForm);
borderForm.Show();

Show (make Visible) the window that is supposed to be on top, later as the other window. 显示(使Visible)应该位于顶部的窗口,稍后显示为另一个窗口。

Topmost only works between non-topmost and topmost windows. 最顶层仅适用于非最顶层和最顶层窗口。 Between Topmost windows, the normal rules apply of what window to show. 在最顶层窗口之间,正常规则适用于要显示的窗口。

为了理解为什么会发生这种情况,我推荐Raymond Chen's 如果有两个程序做了这篇文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM