Monday, April 23, 2012

Textboxes not populating with multiple comboboxes

I have three comboboxes and three columns of textboxes. For some reason only the first combobox I make a selection in is the only one that will populate the appropriate textboxes. I can make any of the three comboboxes my first choice but the only one that will fill its appropriate textboxes is the first one I choose. Here is the code that populates the textboxes. They are exactly the same so I'm not really sure why I'm having this issue. Any help is appreciated.



Well, here's the SelectedIndexChanged for each combobox. I'm not sure that is where the problem is though



    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();
}
}




No comments:

Post a Comment