Reputation: 11731
I have form1 and form2 running at the same time .
The flow is as below
1) Click form1 button
2) disable form1 button
3) show form2 ( form 1 is not closed)
4) click form 2 button
5) close form 2
6) enable form1 button
I have done till 5th step . Couldn't do 6th . Can anyone help ?
Upvotes: 0
Views: 4207
Reputation: 38778
You're right - creating another copy of Form1
is not the right way to go.
It's not very clear from your question, but it sounds like you want to re-enable the same button that you disabled before opening Form2. In that case, you can listen to Form2
's FormClosed
event and handle it in Form1
:
public class Form1 : Form
{
public void ShowForm2()
{
myButton.Enabled = false;
var f2 = new Form2();
f2.FormClosed += HandleForm2Closed;
f2.Show();
}
private void HandleForm2Closed(Object sender, FormClosedEventArgs e)
{
myButton.Enabled = true;
}
}
Upvotes: 3