【问题标题】:Disable MDI Parent when Child is Active子节点处于活动状态时禁用 MDI 父节点
【发布时间】:2014-07-26 00:58:04
【问题描述】:

我的软件中的菜单条,当用户单击“关于”时,我想打开另一个子窗口,但我想禁用父窗口,这意味着只有关闭或单击 kk 才能使其再次可用。

我当前的代码打开了表单,但没有使父级禁用

if (about == null)
            {
                about = new aboutForm();
                about.ShowDialog(this);
            }

我试过 about.ShowDialog();它会引发错误

感谢任何可能的代码解决方案的答案

【问题讨论】:

  • 我不知道这是可能的,因为子表单是父表单的一部分?
  • @ben 不,它没有禁用父表单
  • 点击kk是什么意思?
  • @hassan 我的意思是说有点像 DialogResult.OK 输入返回的密钥的地方。
  • 你试过about.ShowDialog(this)但是你必须评论这行//about.MdiParent = this;

标签: c# winforms mdi opendialog


【解决方案1】:

条件不是必需的,因为ShowDialog(this) 会显示模式对话框。

aboutForm about = new aboutForm();
about.ShowDialog(this);

在aboutForm中

public partial class aboutForm: Form
{      
    public aboutForm()
    {
        InitializeComponent();
    }

    private void aboutForm_Load(object sender, EventArgs e)
    {
       this.FormClosing +=new FormClosingEventHandler(aboutForm_FormClosing);
    }

    private void aboutForm_FormClosing(object sender, FormClosingEventArgs e)
    {
        this.DialogResult = DialogResult.OK;
    }
}

【讨论】:

    猜你喜欢
    • 2020-06-26
    • 1970-01-01
    • 1970-01-01
    • 2018-10-11
    • 2010-11-10
    • 1970-01-01
    • 2018-01-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多