Я получаю пустой экран при запуске моего кода в WinForms. Как исправить?C#

Место общения программистов C#
Anonymous
Я получаю пустой экран при запуске моего кода в WinForms. Как исправить?

Сообщение Anonymous »

Я закончил кодирование, и моя сборка прошла успешно, когда я запускаю код, однако моя форма1 отображается пустой. Ниже мой код.

Код: Выделить всё

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;
}
}
}
Я пытался передвигать вещи, но ничего не получалось.

Подробнее здесь: https://stackoverflow.com/questions/783 ... w-do-i-fix

Вернуться в «C#»