子活动时禁用MDI父级 [英] Disable MDI Parent when Child is Active

查看:79
本文介绍了子活动时禁用MDI父级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的软件中出现菜单栏,当用户单击关于时,我想打开另一个子窗口,但我想使父窗口禁用,这意味着只能通过关闭或单击kk使其再次可用.

I menu strip in my software and when users click on about I want to open the another child window but I want to make the the parent window disabled which means only by closing or clicking kk make it available again.

我当前的代码会打开表单,但不会使父项禁用

My current code opens the form but does not make the parent disable

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

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

I tried about.ShowDialog(); it's throws a error

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

I appreciate any answers possible code solutions

推荐答案

不需要条件,因为ShowDialog(this)将显示模式对话框.

Condition is not required because ShowDialog(this) would show modal dialog.

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;
    }
}

这篇关于子活动时禁用MDI父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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