0

I have 2 forms: form1 and form2.

Form 1 has text boxes and domain up menus asking the user to enter personal information about him/her self, e.g Age, race and form 2 also.

The problem is when going from form1 to form2, and then suddenly the user remembered he/she want to go back to form1 to correct some information, so for this I used a previous button that takes from form2 to form1, but once going back to form1 it is initialized as if the user didn't enter anything.

the question is how do I move button forms back and forth without the textboxes and domainupdown menus losing their information, and no need for the user to reenter the information again. I use Hide() but still the problem exists.

jgauffin
  • 99,844
  • 45
  • 235
  • 372
lilly
  • 1
  • 1

2 Answers2

1

You need to Show() the existing instance of the first form, without creating a new instance.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • How can that be done? Creating an instance as public then using it multiple times? Something like this maybe? public Form1 f1 = new Form1(); Then always using f1.Show(); – Student Dec 05 '21 at 17:14
  • I'm confused as well as f1.Show() cannot be used then from another form then – Student Dec 05 '21 at 17:30
1

You could do something more flexibile, like having those screens populated from an object, which is empty when first accesed, but when switching to screen 2, you take those values from textboxes and put them into the object, and then when you reopen the screen 1 you again populate the textboxes from the object but this time the object isn't empty, so you have your data; and you repeat the process - I hope you get the point.

Denis Biondic
  • 7,943
  • 5
  • 48
  • 79