Disable MDI Parent when Child is Active

685 Views Asked by At

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

There are 1 best solutions below

0
On BEST ANSWER

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