tags:

views:

64

answers:

3

New to C# and .NET.

In a windows application I place a form to query a user for some input. The user fills out the form and presses 'ok'.

What is the "correct" or "appropriate" method of retrieving that data from the form? Do forms have a return statement? Do I send a message?

Thanks in advance.

+1  A: 

you can have the parent form subscribe to events from the child form and still do the same thing or put the form results into an event arg statement

you should listen to the click event of the button and you will get a call back and you can simply read the properties from the form objects (txtBox.Text, etc . . )

ooo
I understand reading them in place, but I need the data in the parent form.
Präriewolf
you can have the parent form subscribe to events from the child form and still do the same thing or put the form results into an event arg statement
ooo
+2  A: 

This question has been asked in a slightly different form on SO; please see my answer here.

Mitch Wheat
A: 

After they press OK, the form will close, but (as long as the form variable is still in scope), its members will still contain all of the data. Save the input to 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 closing event and get the information then.

Steve