Reputation: 11
I'm making a program that consists of series of forms and these form asks the user to enter values in text boxes, and choose values from domainupdown menu, and when I go to next form which is form2 , then go back to form1 by previous button located in form2, I see that form1 returned initialized and all text boxes are empty. how can I save form1 values when I go back to the it from form2.
Upvotes: 1
Views: 1225
Reputation: 13116
You can save values to a database or you can create a container class and pass it through various forms.
Upvotes: 0
Reputation: 16709
You're going to need to do some modelization.
Think of a form as a temporary entity (because it is). The data you're entering there needs to be put in an object (or static class) of some kind. That way you can have your program keep the form 1's information in the object, then when the form is shown again you can repopulate all the text fields.
A small hack would be to hide the form instead of closing it.
Upvotes: 0
Reputation: 1600
It sounds like what you're trying to do is create a wizard which would help rather than having to manage the data yourself. Tutorial: http://msdn.microsoft.com/en-us/library/7k3w6w59%28v=VS.100%29.aspx
If you want to persist data across executions, you can save the data to a resource string of the project. Info on Resource Strings: http://msdn.microsoft.com/en-us/library/7k989cfy%28v=vs.80%29.aspx You can programatically save resource strings on formclose and re-read them on initialize to make them persist.
Upvotes: 1