Reputation: 35557
When the button is clicked a second form 'uxDGVdatabase' is shown and the controls in the calling form are disabled. When the user closes uxDGVdatabase I'd like the controls in uxRevisionHelperForm to be enabled again.
So I've assumed that I'll need to use a delegate to do this? In uxRevisionHelperForm I have the following:
public delegate void myDelegate();
private void updateDataButton_Click(object sender, EventArgs e)
{
myDelegate letsTryThis = new myDelegate(activateGroupBorder);
uxRevisionHelperGroupBox.Enabled = false;
uxDGVdatabase myNewDisplay = new uxDGVdatabase();
myNewDisplay.Show();
}
public void activateGroupBorder() {
uxRevisionHelperGroupBox.Enabled = true;
}
In uxDGVdatabase I have the following - what code needs to go in here?
private void uxDGVdatabase_closed(object sender, FormClosedEventArgs e)
{
}
Upvotes: 1
Views: 73
Reputation: 941208
You put the event handler in the wrong class. You'll want it like this:
uxRevisionHelperGroupBox.Enabled = false;
uxDGVdatabase myNewDisplay = new uxDGVdatabase();
myNewDisplay.FormClosed += delegate { uxRevisionHelperGroupBox.Enabled = true; }
myNewDisplay.Show();
Keep in mind that events are useful to code in another class.
Upvotes: 3