我正在编写一个具有三个选项卡的程序。
在第一个选项卡上,用户输入有关客户帐户的信息,然后将其发送到名为combobox
的第二个和第三个选项卡上clients
。在第二个选项卡上,用户输入有关股票或共同基金的信息。股票信息转到combobox
第三个选项卡上的股票,共同基金信息转到combobox
第三个选项卡上的共同基金。
我遇到的问题是我只能填写一个信息字段,并且能够textboxes
使用combobox
. 例如,如果我输入有关客户帐户的信息——然后在其中选择该选项combobox
——它将填充textboxes
该信息。但是,如果我尝试从股票或共同基金中选择一个选项combobox
,那么相应textboxes
的信息将不会填充。我不知道为什么第一个选择combobox
是唯一会填充textboxes
.
这是填充的代码textboxes
:
private void cboClientsTab3_SelectedIndexChanged(object sender, EventArgs e)
{
CustomerAccount custAccount = account[cboClientsTab3.SelectedIndex] as CustomerAccount;
if (custAccount != null)
{
txtAccountNumberTab3.Text = custAccount.GetAccountNumber();
txtCustomerNameTab3.Text = custAccount.GetCustomerName();
txtCustomerAddressTab3.Text = custAccount.GetCustomerAddress();
txtCustomerPhoneNumberTab3.Text = custAccount.GetCustomerPhoneNo();
}
}
private void cboStocksTab3_SelectedIndexChanged(object sender, EventArgs e)
{
Stock aStock = account[cboStocksTab3.SelectedIndex] as Stock;
if (aStock != null)
{
txtStockIDTab3.Text = aStock.GetInvestmentID();
txtStockNameTab3.Text = aStock.GetInvestmentName();
txtStockSymbolTab3.Text = aStock.GetInvestmentSymbol();
txtStockSharesTab3.Text = aStock.GetInvestmentShare().ToString();
txtStockPriceTab3.Text = aStock.GetStockPrice().ToString();
}
}
private void cboMutualFundsTab3_SelectedIndexChanged(object sender, EventArgs e)
{
MutualFund aMutualFund = account[cboMutualFundsTab3.SelectedIndex] as MutualFund;
if (aMutualFund!=null)
{
txtMutualIDTab3.Text=aMutualFund.GetInvestmentID();
txtMutualNameTab3.Text=aMutualFund.GetInvestmentName();
txtMutualSymbolTab3.Text=aMutualFund.GetInvestmentSymbol();
txtMutualSharesTab3.Text=aMutualFund.GetInvestmentShare().ToString();
txtNAVTab3.Text=aMutualFund.GetNAV().ToString();
}
}