在MDI窗体控件问题 [英] Problem with controls in MDI form
问题描述
我已经放在MDI形式的按钮,现在当我打开一个子窗体,按钮仍然在顶部,分散了孩子的形式,有没有办法解决呢? 我做了以下发送按钮回来时,所有的孩子activated.But我想知道叫button1.BringToFront();
I have placed a button on MDI form , now when I open a child form , the button remains on top and distracts the child form , is there a way to solve it? I have done following to send the button back when any child is activated.But I am wondering to call button1.BringToFront();
private void MDIParent1_MdiChildActivate(object sender, EventArgs e)
{
button1.SendToBack();
}
我尝试以下,但它不工作。
I tried following but it doesnt work.
private void MDIParent1_Enter(object sender, EventArgs e)
{
button1.BringToFront();
}
我觉得.NET其持久的漏洞,还有很多帖子试图解决它,使用多功能底座板等,但对接只是一个按钮,使应用程序的工作空间更小。
I think its a lasting bug of .net , there are many posts trying to solve it , using dock with a panel etc , but docking just for a button makes the application work space less.
推荐答案
我找到了答案,我的问题!这里是我是如何实现它,后这里是我失踪了。
I found the answer to my question ! here is how I implemented it , the post here was what I was missing.
public MDIParent1()
{
InitializeComponent();
foreach (var ctl in this.Controls)
{
if (ctl is MdiClient)
{
(ctl as MdiClient).GotFocus += Client_gotfocus;
(ctl as MdiClient).LostFocus += Client_lostfocus;
break;
}
}
}
private void Client_gotfocus(object sender, EventArgs e)
{
button1.BringToFront();
}
private void Client_lostfocus(object sender, EventArgs e)
{
button1.SendToBack ();
}
这篇关于在MDI窗体控件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!