我有两个对话框, FORMA
和 FormB
。我用下面的code显示(无模式) FormB
。在code是点击一个按钮,从 FORMA
。
I have two dialogs, FormA
and FormB
. I use the following code to show (modeless) FormB
. The code is a button click executed from FormA
.
private void button_Click(object sender, EventArgs e)
{
FormB fB = new FormB();
fB.Show(this); // FormA is the owner of FormB
}
现在的问题是,当 FormB
超过 FORMA
在屏幕上,如果我点击 FORMA
,它被激活,但没有引起面前。其实FormB总是超过FORMA
The problem is that when FormB
is over FormA
on the screen, if I click FormA
, it is activated, but not brought to front. Actually FormB is always over FormA
你知道为什么,以及如何改变这种行为,不删除所有者的财产?
Do you know why, and how to change this behavior, without remove the owner property?
注意:这是我的问题简单化。在真正的问题,FORMA是一个Windows资源管理器窗口,并FormB是一个管理的WinForm的,但行为是一样的。如果我不通过IWin32Window到显示()
,它工作正常,但如果我关闭A,B不闭合,它不响应事件(请参阅下面的entry).
NOTE: This is a simplification of my problem. In the real problem, FormA is a Windows Explorer window, and FormB is a managed WinForm, but the behavior is the same. If I do not pass the IWin32Window to Show()
, it works fine, but If I close A, B is not closed and it does not respond to events (see the following entry).
您不能这样做不删除所有者属性。
You cant do this without removing the owner property.
从技术文档: 拥有形式也永远不会显示背后的所有者的形式。
From Documentation: Owned forms are also never displayed behind their owner form.
来源:的http:// MSDN。 microsoft.com/en-us/library/system.windows.forms.form.owner.aspx
有关您的具体问题,你为什么不听的关闭事件,然后明确地关闭自己的形式?
For your specific problem why do you not listen for the Close Event and then explicitly close your own form?