是否可以创建一个仅阻止其父级的对话框? [英] Is it possible to create a dialog which only blocks its parent?

查看:38
本文介绍了是否可以创建一个仅阻止其父级的对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有一个全局菜单和一些 MDI 子项(在选项卡管理器中).每个 MDI 子节点都应该单独运行.我希望 MDI 子级能够显示仅阻止其父级的模态对话框,而不是应用程序中的其他 MDI

My application has a global menu and some MDI children (in a Tab Manager). Each MDI Child should behave separately. I would like an MDI child to be able to show a modal dialog that only blocks its parent, and not the other MDIs in the application

当我显示来自 MDI 子级的模态表单时,所有 MDI 子级都被阻止.如何创建仅阻止其父级输入的对话框?

When I display a modal form from an MDI child, all MDI children are blocked. How can I create a dialog that only blocks input on its parent?

推荐答案

您可以禁用打开的 Form 而不是使 modal child 真正成为 modal..

You can disable the opening Form instead of making the modal child truly modal..

你可以试试这个:用

this.Enabled = false;
FormDlg yourModalChildForm= new FormDlg(this);
yourModalChildForm.Show();

在构造函数中写:

    Form myParent;

    public FormDlg(Form myParent_)
    {
        InitializeComponent();
        myParent = myParent_;
    }

并在 FormClosed 中写入:

And in the FormClosed write:

  private void FormDlg_FormClosed(object sender, FormClosedEventArgs e)
  {
      myParent.Enabled = true;
  }

这篇关于是否可以创建一个仅阻止其父级的对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆