Weird Behavior in ShowDialog()

  • Thread starter Thread starter Sean
  • Start date Start date
S

Sean

Hi all,

I have a main window application Form A that calls
ShowDialog() of Form B in the Click event of Form A.

Sometimes when I hit the cancel button on Form B, Form B
closes and SURPRISINGLY Form A closes as well (ie. the
whole application exits).

Anyone knows what happens here?

Any help or reference to helpful articles would be greatly
appreciated.
Thank you.

regards,
Sean
 
Sean said:
I have a main window application Form A that calls
ShowDialog() of Form B in the Click event of Form A.

Sometimes when I hit the cancel button on Form B, Form B
closes and SURPRISINGLY Form A closes as well (ie. the
whole application exits).

Maybe assigning 'None' to the button's 'DialogResult' and adding this code
to the button's 'Click' event handler solves the problem:

\\\
Me.DialogResult = DialogResult.Cancel
Me.Close()
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top