我正在编写一个带有两个选项卡的程序。在第一个选项卡上,用户输入有关客户帐户的信息。On the second tab there is a combobox which holds the account's name and when selected the same information entered on the first tab being stored should populate the textboxes with the same information on the second tab. 我以前做过这个,我使用的是相同的结构,但它不起作用。我也正在从关联的类中提取这些信息,但一切看起来都正确。有人可以告诉我出了什么问题。
public partial class Form1 : Form
{
ArrayList account;
public Form1()
{
InitializeComponent();
account = new ArrayList();
}
//here we set up our add customer button from the first tab
//when the information is filled in and the button is clicked
//the name on the account will be put in the combobox on the second tab
private void btnAddCustomer_Click(object sender, EventArgs e)
{
try
{
CustomerAccount aCustomerAccount = new CustomerAccount(txtAccountNumber.Text, txtCustomerName.Text,
txtCustomerAddress.Text, txtPhoneNumber.Text);
account.Add(aCustomerAccount);
cboClients.Items.Add(aCustomerAccount.GetCustomerName());
ClearText();
}
catch (Exception)
{
MessageBox.Show("Make sure every text box is filled in!", "Error", MessageBoxButtons.OK);
}
}
private void ClearText()
{
txtAccountNumber.Clear();
txtCustomerName.Clear();
txtCustomerAddress.Clear();
txtPhoneNumber.Clear();
}
这就是我遇到麻烦的地方。它说没有“accountNumber”或任何其他的定义
private void cboClients_SelectedIndexChanged(object sender, EventArgs e)
{
txtAccountNumberTab2.Text = account[cboClients.SelectedIndex].accountNumber
txtCustomerNameTab2.Text = account[cboClients.SelectedIndex].customerName;
txtCustomerAddressTab2.Text=account[cboClients.SelectedIndex].customerAddress;
txtCustomerPhoneNumberTab2.Text=account[cboClients.SelectedIndex].customerPhoneNo;
}