1

I have a modal form but I need to change it to modeless. The form's purpose is to receive user input, either click OK or Cancel, then continue with further functionality in the same method. I know the sources I've found say just to change form.ShowDialog() to form.Show(), but I'm having trouble with it. When I change it to form.Show(), code continues to be hit and the dialog box doesn't pop up until the entire method has been hit. How do I open the form and handle it within the one method I have?

Sorry if this is poorly worded, still trying to grasp concepts with C#! Thanks!

  • If you want the code in your method to wait for user input from the form, then the form must be modal. – Honeyboy Wilson Dec 09 '15 at 19:00
  • The `ShowDialog` method will block the thread on that statement until the shown form is closed. The `Show` method however, will show the form and continue to run any code after. – test Dec 09 '15 at 19:01
  • Hook up a closed event in you method and call the continuation – Sievajet Dec 09 '15 at 19:01
  • Change it to Show() and move the remaining code to a new function. Register with that new forms on_closing or on_closed event to call the new function where it will continue once the form is closed. – Moon Dec 09 '15 at 19:06

0 Answers0