将鼠标单击从2到From 2传递到Form1 C#
当我显示一些标签时,我做了辅助表单,当我单击表单外部(在主表单内)表单关闭时,但主表单不集中时,我必须在表单中再单击2个单击以进行聚焦。
主形式
private void btn_Notifications_Click(object sender, EventArgs e)
{
NotiCenter notiForm = new NotiCenter();
notiForm.Show(this);
}
secundary表格
private void NotiCenter_Deactivate(object sender, EventArgs e)
{
MainUI MainForm = GetFormOwner();
this.Close();
MainForm.Focus();
}
private MainUI GetFormOwner()
{
MainUI MainForm = (MainUI)this.Owner;
if (MainForm == null) throw new Exception("Form owner not found");
return MainForm;
}
我使用屁股显示表单,我使用停用事件来关闭表单。 当我单击主形式时,辅助形式关闭,但主形式忽略了主形式中任何控件中的单击;
“ https://i.sstatic.net/pru7i.png” form
I made a secondary form when I display a few labels, when I click outside the form (inside the primary form) the form close but the primary form is not focused, I have to press 2 more clicks in the form to be focused.
Primary form
private void btn_Notifications_Click(object sender, EventArgs e)
{
NotiCenter notiForm = new NotiCenter();
notiForm.Show(this);
}
Secundary form
private void NotiCenter_Deactivate(object sender, EventArgs e)
{
MainUI MainForm = GetFormOwner();
this.Close();
MainForm.Focus();
}
private MainUI GetFormOwner()
{
MainUI MainForm = (MainUI)this.Owner;
if (MainForm == null) throw new Exception("Form owner not found");
return MainForm;
}
I use a buttom to show the form and I use Deactivate event to close the form.
When I click in the primary form, the secondary form close but the primary form ignore the click in any control in the primary form;
Another question, the buttom in the primary form is show like Im holding the click in the buttom after I display the form
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论