I have an MDIParent form with a button in it. I have it so that when i click the button it gets disabled. What i need help on is that, I need to know how to re-enable the button after i exit out of the form that opens when i click the button.

Thanks,
NH1

Edited 6 Years Ago by NH1: n/a

So, you have Child Form which opens from the button... you'll implement the event Form Closed of the Child Form to execute this piece of code

yourButton.Enabled = true;

So, you have Child Form which opens from the button... you'll implement the event Form Closed of the Child Form to execute this piece of code

yourButton.Enabled = true;

The Problem with that is when i do that there is an error.
"
ToolStripButton3.Enabled = true;
"
The error says this; The name "toolStripButton3" does not exist in the current context;

Please clarify, where the button is? Parent Form or the Child one? and tell me the exact scenario.

The Button is in the Parent form. The button opens a child form. When i click the button, opening the the child form, the button gets disabled.
I need to know how to re-enable the button when i exit the child form.

//Global Variables
Form frmChild;

private void button1_Click(....)
{
//show child form
frmChild=new Form();
frmChild.MDIParent=this;
frmChild.Show();
frmChild.FormClosed+=new FormClosedEventHandler(frmChild_FormClosed);
//disable your button
button1.Enabled = false;
}

void frmChild_FormClosed(object sender, EventArgs e)
{
button1.Enabled = true;
}
//Global Variables
Form frmChild;

private void button1_Click(....)
{
//show child form
frmChild=new Form();
frmChild.MDIParent=this;
frmChild.Show();
frmChild.FormClosed+=new FormClosedEventHandler(frmChild_FormClosed);
//disable your button
button1.Enabled = false;
}

void frmChild_FormClosed(object sender, EventArgs e)
{
button1.Enabled = true;
}

Thanks that worked.

This question has already been answered. Start a new discussion instead.