[英]c# mainui drops behind other windows, issue with topmost
我在最高级别上遇到问题,找到了一个可以“工作”的解决方案,但看起来不太好。 还有另一种“更清洁”的方法可以解决此问题吗? 这是我的代码:代码中事件的注释。
OrderTemplateView template;
private void toolStripButton4_Click(object sender, EventArgs e)
{
if (template != null)
{
template.Close(); //must close to trigger close event.
template.Dispose();
}
mainUi.TopMost = true; // must set my mainUi topMost here othervise it drops in the background of other windows open at the computer.
template = new OrderTemplateView(this);
template.TopMost = true;// must set my dialog topmost othervise it drops behind my mainUi
template.StartPosition = FormStartPosition.CenterParent;
mainUi.TopMost = false;//must release my topmost so other windows on the computer can be called to front.
template.TopMost = false;
template.ShowDialog();
}
更新的代码执行相同的工作:
private void toolStripButton4_Click(object sender, EventArgs e)
{
if (template != null)
{
template.Close();
template.Dispose();
}
template = new OrderTemplateView(mainUi);
template.StartPosition = FormStartPosition.CenterParent;
template.ShowDialog(mainUi);
}
`
而不是设置TopMost,请尝试以下操作:
删除所有对TopMost
的引用
调用mainUi.BringToFront()
调用template.ShowDialog(mainUi)
,注意将父控件传递到对话框。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.