What is wrong with this winform code

Vijayadithyan .N 121 Reputation points

I wrote some code for a quiz app I'm trying to make which goes like this:

and it shows this error on the form:

the form shows up in the executable but the code doesn't work as intended.
how do I fix it?

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,823 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,206 questions
{count} votes

2 answers

Sort by: Most helpful
  1. RLWA32 40,021 Reputation points

    The error message issued by the Form designer is clear -- Remove the manually inserted code from the InitializeComponent method. Try moving the manually inserted code to the Form's Load event handler.

    1 person found this answer helpful.
    0 comments No comments

  2. Keshav Kumar 1 Reputation point

    I agree with answer of RLWA32-6355. After rolling back your changes, try double clicking the form in designer mode and it should insert a Form1_Load method automatically for you. Try adding your code in there in Form1.cs file in place of in Form1.designer.cs file. Also, I overserved that your if condition does not have colon after Health . May be you have displayed the code only for sample, but a point to look at something to fix your code.

    0 comments No comments