What is wrong with this if combobox selectedtext statement?

The combobox "PanelAddComboBoxCurrency" is selected to GBP so it when typing numbers into it it should populate some other textboxes, doesnt seem to work though?


private void PanelAddTextBoxSubTotal_Leave(object sender, EventArgs e)
        {
            if (PanelAddTextBoxSubTotal.Text == "")
            {
            }
            else if(PanelAddComboBoxCurrency.SelectedText == "GBP")
            {
                double Subtotal = Convert.ToDouble(PanelAddTextBoxSubTotal.Text);
                double VAT = (Subtotal / 100 * 17.5);
                double Total = (Subtotal + VAT);

                PanelAddTextBoxVAT.Text = Convert.ToString(VAT);
                PanelAddTextBoxTotal.Text = Convert.ToString(Total);
            }
        }
Antonio KingIT ManagerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Babycorn-StarfishConnect With a Mentor Commented:
try .Text instead of SelectedText
0
 
Antonio KingIT ManagerAuthor Commented:
Nope no difference.
0
 
CuteBugCommented:
I think you are subscribing to the Leave event of the ComboBox.

Instead you should try to subscribe to the SelectedValueChanged event.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Antonio KingIT ManagerAuthor Commented:
the content of the textboxes PanelAddTextBoxVAT and PanelAddTextBoxTotal need to change depending on the combobox value WHEN a textbox PanelAddTextBoxSubTotal is changed.
0
 
Antonio KingIT ManagerAuthor Commented:
Worked :)
0
 
Antonio KingIT ManagerAuthor Commented:
Sorry Babycorn-Starfish, changing Selectedtext to Text DID work. Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.