Keep form values

Hi experts

Using C# i have  2 forms with controls on them, i want to be able to go to form2 (do some calculations) and then go back to form1 whilst keeping all of the selected values in form1, if I use
public f1 = new Form1();

then all of the comboboxs ect in form1 are cleared of their values because I have created a new instance of the form1 object.

Hope somebody can help
Who is Participating?
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
You should hide Form1, then display  Form2 with ShowDialog() which causes execution in Form1 to STOP until Form2 is dismissed.  Afterwards you can simply show Form1 again.

Here's a simple example:
// ... running from withing Form1 ...

Form2 f2 = new Form2();


Open in new window

You could also do this without hiding Form1 at all.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.