Reputation: 21
I have two forms. I have a button in mainForm. When i clicked button1 the main form will show and the button1 will be Enabled false. Now i want to Enable it to True when my ChildForm gets Close. PLease help me . My code For Enable= False is
CstmersFrm cstFm = new CstmersFrm();
cstFm.MdiParent = this;
cstFm.Show();
cstFm.BringToFront();
btnCstmr.Enabled = false;
Iam trying to Enable= True is In cstmersFrm _Closed Event
mFrm = (mainForm)this.MdiParent;
mFrm.btnCstmr.Enabled = true;
Upvotes: 0
Views: 1154
Reputation: 2242
You need to register to the child form Closed event on the main form:
Form child = new Form();
child.MdiParent=this;
child.Show();
child.FormClosed+=child_FormClosed;
and then set the button to Enabled:
void child_FormClosed(object sender, FormClosedEventArgs e)
{
btnCstmr.Enabled = true;
}
Upvotes: 3