Enable a button
Hi,
I am still learning C#. I am able to work out how to do most things that I need, but there are still some areas that cause me great problems.
One thing that I am trying to do is to Enable a Button on a form when a button on a second form is clicked. This is to ensure that the second form is closed and parameters set on this panel are updated before my main program can be started.
I have set the Modifiers property to Public, but I still can't see the button control from my second form. Am I missing something?
Any help will be most welcome.
Regards
John Woodiwiss
If you call second from from the first one, you can use dialog behaviour that can be arranged. Set to that button on second form DialogResult to be OK. Then from first form run this code:
formSecond frm = new frmSecond();
if (DialogResult.OK == frm.ShowDialog())
{
//your button is clicked
}
else
{
//do something else
}
In the Second form set the DialogResult property of that button to OK. then show this form from the main from using ShowDialog like this:
Form2 frm2 = new Form2();
if(frm2.ShowDialog() == DialogResult.OK)
this.btnTest.Enabled = true;
else
this.btnTest.Enabled = false;
frm2.Dispose();
and dont forget to call frm2.Dispose() when you call ShowDialog becuase it still sits in the memory after closing it.
Cheers ;-)