Präriewolf
Präriewolf

Reputation: 819

Appropriate Method of Retrieving Data from a Form

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.

Upvotes: 0

Views: 152

Answers (2)

leora
leora

Reputation: 196679

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 . . )

Upvotes: 1

Steve
Steve

Reputation: 12004

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.

Upvotes: 0

Related Questions