Appropriate method for retrieving data from a form
New to C # and .NET.
In a windows app, I put a form to ask the user for some input. The user fills out the form and clicks "ok".
What is the "correct" or "appropriate" method to retrieve this data from a form? Do forms have a return statement? Send a message?
Thanks in advance.
This question has been asked in a slightly different form on SO; see my answer here .
you can have a parent form to subscribe to events from the child form and still do the same, or put the results of the form in the arg statement of events
you have to listen for the button click event and you will get a callback and you can just read the properties from the form objects (txtBox.Text etc.).
After they click OK, the form will close, but (as long as the form variable is still in scope) its members will still contain all the data. Store the input in a member variable and access it from your main program using an accessor. If the form is not modal, your main program can subscribe to the form's close event and then retrieve the information.