Show input dialog in WinForms

I want to show the input modal in a WinForm application. I browsed the web but did not find a good template for this. I understand that I need to create another form and use the ShowDialog method.

+4
source share
1 answer

You're right.

Please note that modal dialogs will not be automatically deleted upon closing (unlike non-modal dialogs), so you need a template, for example:

using (FrmModal myForm = new FrmModal()) { DialogResult dr = myForm.ShowDialog(); if (dr == DialogResult.OK) { // ... } else { // ... } } 

In the newest form (which I called FrmModal) set the DialogResult property in the button event handlers accordingly, for example. if you have an OK button, you want to set DialogResult = DialogResult.OK to the event handler for that button, and then call Close () to close the form.

+15
source

All Articles