Disable MDI Parent when Child is Active

情到浓时终转凉″ 提交于 2019-12-20 05:45:56

问题


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

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

I appreciate any answers possible code solutions


回答1:


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

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

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


来源:https://stackoverflow.com/questions/24053309/disable-mdi-parent-when-child-is-active

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!