【发布时间】:2016-02-01 08:58:05
【问题描述】:
我是 C# 的新学生,正在使用 Microsoft Visual C# 2013。
我的目标是
- 在其 MDIparent 表单中打开一个子表单
- 当子窗体处于活动/打开状态时禁用 MDIparent 窗体
使用 VB.net 更容易
frmStuDetails.ShowDialog()
我试过了
1.
MyChildForm childForm = new MyChildForm();
childForm.ShowDialog(this);
结果....但问题是子表单没有在 MDIparent 表单/容器中打开
2。 在 MDI 父调用按钮下
frmViewStuList childForm = new frmViewStuList(this);
childForm.Owner = this;
childForm.Show();
childForm_Activated下
if (this.Owner != null)
{
this.Owner.Enabled = false;
}
childForm_Deactivate下
if (this.Owner != null)
{
this.Owner.Enabled = true;
}
结果.....它使子窗体处于活动状态,但在子窗体关闭时冻结 MDIparent
3.
ChildForm child = new ChildForm();
child.Owner = this;
child.Show();
// In ChildForm_Load:
private void ChildForm_Load(object sender, EventArgs e)
{
this.Owner.Enabled = false;
}
private void ChildForm_Closed(object sender, EventArgs e)
{
this.Owner.Enabled = true;
}
结果 ....这似乎是最好的选择,但子窗体没有在 MDIparent 中打开
如果您有任何其他想法,请提供帮助
谢谢
【问题讨论】:
标签: c#