The button on my Windows form does not work. Visual Studio has no errors in my code


I have a average calculator Windows Form application that asks the user how many scores they would like to enter. A textbox accepts the input and once they click OK, the number they entered becomes textboxes for them to enter scores into. Once the textboxes are populated, they can click calculate to calculate the average which is displayed to them.

My problem is, when I enter a number in the textbox, and click OK, nothing happens.

Please help, here is my code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AverageCalculator
public partial class AverageCalculator : Form
    //Private instance variable, Scores, which is an array of TextBox objects.
    //Do not instantiate the array.
    private TextBox[] Scores;

    // Create a Form_Load event hadler
    private void Form_Load(object sender, EventArgs e)
        // Set the visible property of btnCalculate to false
        btnCalculate.Visible = false;
    } // end Form_Load event handler

    //Create the Click event handler for the OK button
    private void btnOK_Click(object sender, EventArgs e)
        // Declare an integer, intNumTextBoxes
       int intNumTextBoxes;

        //Store the number of text boxes to be created into the integer
        intNumTextBoxes = Convert.ToInt32(txtNumScores.Text);

        // Set the height of the form to 500 pixels
        this.Height = 500;

        // Set the visible property of btnCalculate to true
        btnCalculate.Visible = true;

        // Set the enabled property of btnOK to false
        btnOK.Enabled = false;

        // Call CreateTextBoxes and pass it the integer, intNumTextBoxes as a parameter

    // CreateTextBoxes method
    private void CreateTextBoxes(int number)
        //Instantiate the Scores array and use the parameter "number" as the size of the array
        Scores = new TextBox[number];

        //Declare an integer, intTop, with an initial value of 150
        int intTop = 150;

        //Loop through the entire array, Scores
        for (int i = 0; i < Scores.Length; i++)
            // Instantiate a new TextBox using the default
            // constructor and assign it to the current element
            // of the Scores array
            Scores[i] = new TextBox();

            // Set the left property of the TextBox to 20.
            Scores[i].Left = 20;

            // Set the Top property of the Textbox to intTop
            Scores[i].Top = intTop;

            // Increment intTop by 50
            intTop += 50;

            // Ad the TextBox to the controls collection of the Form
        } // end for loop
    } // end CreateTextBoxes method

    // Create the Click event handler for the btnCalculate button
    private void btnCalculate_Click(object sender, EventArgs e)

    public AverageCalculator()



are you sure your event is bind to the correct event of the button (verify in Properties/Event) it happens to me sometime, idiot mistake