Im getting a blank screen when running my code in winforms. How do I fix?

  Kiến thức lập trình

I have finished coding and my build succeeds when I run the code however my form1 shows up blank. Below is my code.
namespace AccountsApp
{
public partial class Form1 : Form
{
private List accounts = new List();
private TextBox accountNumberTextBox = new TextBox();
private TextBox clientNameTextBox = new TextBox();
private TextBox balanceTextBox = new TextBox();
private TextBox limitTextBox = new TextBox();
private TextBox interestTextBox = new TextBox();
private RadioButton checkingRadioButton = new RadioButton();
private RadioButton savingsRadioButton = new RadioButton();

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void CreateAccountButton_Click(object sender, EventArgs e)
    {
        try
        {
            int number = int.Parse(accountNumberTextBox.Text);
            string name = clientNameTextBox.Text;
            double balance = double.Parse(balanceTextBox.Text);

            if (checkingRadioButton.Checked)
            {
                double limit = double.Parse(limitTextBox.Text);
                accounts.Add(new CheckingAccount(number, name, balance, limit));

            }

            else if (savingsRadioButton.Checked)
            {
                double interest = double.Parse(interestTextBox.Text);
                accounts.Add(new SavingsAccount(number, name, balance, interest));

            }

            MessageBox.Show($"Total Number of accounts: {accounts.Count}");

        }

        catch (Exception ex)
        {
            MessageBox.Show($"Error: {ex.Message}");
        }
    }

    private void ClearFields()
    {
        accountNumberTextBox.Clear();
        clientNameTextBox.Clear();
        balanceTextBox.Clear(); 
        limitTextBox.Clear();
        interestTextBox.Clear();
        checkingRadioButton.Checked = true;
    }
}

}

I tried to move things around but nothing worked.

New contributor

AdrianTB12345 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

LEAVE A COMMENT