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

[625 byte] By [JohnWoodiwiss] at [2007-12-24]
# 1

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
}

boban.s at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# General...
# 2

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 ;-)

RizwanSharp at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# General...
# 3

Many thanks for your reply. I will try this out over the weekend.

John

JohnWoodiwiss at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# General...
# 4

Hi

Many thanks for this, I will try it out over the weekend, when my brain has had a bit of a rest!

John

JohnWoodiwiss at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# General...