I'm making a quiz and I'm having problems with transferring the text of the score label from one form to another. could use some help on how to do that. in the quiz, you start from a score of 0 and build your way up. for every right answer, you get 10 points and move to a new form. I need to find a way to keep the score in the new form.
Asked
Active
Viewed 64 times
0
-
Ether pass it as param to another form or make it public an get it in the second form. – Andreas Schmidt Oct 11 '19 at 22:48
-
1A new Form for each question? You probably want to work on this. You need just one Form. Anyway, you could add a public Property to your Forms (I assume you don't have a Form model either) that accepts a suitable value type that you can assign to a child control. E.g., in `Form1`: `var form2 = new Form2(); form2.ThePublicProperty = theCurrentScore; form2.Show();` When the setter of `ThePublicProperty` is called, assign its `value` to a control. – Jimi Oct 11 '19 at 22:50
-
1You could also add a constructor that accepts an argument to each Form (you'll have to move `InitializeComponent()`, though, and redirect the default constructor). – Jimi Oct 11 '19 at 22:55
1 Answers
0
Why you use a new form for every level? You can take advantage of TabControl, and also you can make it look like a wizard, or simply switch between indexes for different levels.

Nabi Sobhi
- 369
- 4
- 16