Discussion: Returning from "dialog" forms
[u]Scenario</u>:
We have a windows forms application. In it is FormA. It needs to pop open FormB as a dialog to ask the user for some information. FormB has an "OK" and "Cancel" button. If "OK" is clicked, then FormA should do something. If "Cancel" is clicked, then FormA should do nothing.
[u]Possible Solutions</u>:
1. Show FormB modally such that FormB is displayed and FormA waits for it to close before continuing its code execution. Then FormA looks at a public property on FormB for information about what happened ("OK" or "Cancel") and also looks at a public property for the "return" information.
2. FormA shows FormB and continues. (Presumably the logic to show FormB is in a click handler, and nothing else happens.) Then, when a FormB button is clicked a public event is raised and FormA handles the event and performs the necessary actions respective of the event.
Questions:
Which makes more sense?
Which follows the .NET model better? (Is #2 more appropriate for the event driven paradigm of .NET?)
Which do you prefer?
|