Nathanial s-c
Nathanial s-c

Reputation: 31

C# how to disable a child form of a MDI parent when a different child form is open

so the title say it all kinda. I have an MDI parent that opens up a child that lets me view a data grid but this child lets me select a row and open up a different child from of the parent that lets me edit the data row. how do i disable the previous child till the current one is closed. kinda like ShowDialog() but for child forms ?

any help would be great :)

Upvotes: 0

Views: 762

Answers (2)

David
David

Reputation: 1873

Disable the form when you open the new one and re-enable on the form closed event of the child form

Wherever you are opening the child form:...

{
   ChildForm f = new ChildForm();
   f.FormClosed += F_FormClosed;
   f.Show();
   this.Enabled = false;
}

and

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

Upvotes: 2

Sergey Slepov
Sergey Slepov

Reputation: 2111

How about this?

this.MdiParent.MdiChildren[0].Enabled = false;

Upvotes: 0

Related Questions