I have a main form (let's call it frmHireQuote) that is a child of a main MDI form (frmMainMDI), that shows another form (frmImportContact) via ShowDialog() when a button is clicked.
When the user clicks the 'OK' on frmImportContact, I want to pass a few string variables back to some text boxes on frmHireQuote.
Note that there could be multiple instances of frmHireQuote, it's obviously important that I get back to the instance that called this instance of frmImportContact.
What's the best method of doing this?
Best Answer
Create some public Properties on your sub-form like so
then set this inside your sub-form ok button click handler
Then in your frmHireQuote form, when you open the sub-form
Additionaly if you wish to cancel out of the sub-form you can just add a button to the form and set its DialogResult to
Cancel
and you can also set the CancelButton property of the form to said button - this will enable the escape key to cancel out of the form.