Try This:-
Create variable in your form. I wrote double because price may in point for eg. 27.50
double a, b,c;
then I dropped 1 combobox, and 2 textbox controls.
then write following code:-
1. First in Combo box selected Index event:-
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedValue != "")
{
if (textBox1.Text != "")
{
a = Convert.ToDouble(textBox1.Text);
b = Convert.ToDouble(comboBox1.SelectedItem.ToString());
c = (a * b) / 100;
textBox3.Text = (a - c).ToString();
}
}
}
2. Then in textbox changedvalue event of textbox 1:-
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
a = Convert.ToDouble(textBox1.Text);
b = Convert.ToDouble(comboBox1.SelectedItem.ToString());
c = (a * b) / 100;
textBox3.Text = (a - c).ToString();
}
}
I wrote the same code in Combobox selected index changed event because if the user changes the discount % then the price should be calculated again.
Any query plz reply or comment.
If You Found the answer correct then accept as solution.