@MiPakTeh , you could try the following code to get the result after you choose the value from combobox1 and combobox2.
public partial class Form1 : Form
{
List<string> Quantity = new List<string>();
List<string> Unit_Price = new List<string>();
NumberStyles currencyStyle = NumberStyles.Currency;
NumberFormatInfo numberFormat = CultureInfo.CurrentCulture.NumberFormat;
public Form1()
{
InitializeComponent();
CultureInfo.CurrentCulture = new CultureInfo("en-US");
for (int i = 1; i < 100; i++)
Quantity.Add(i.ToString());
foreach (string item in Quantity)
{
comboBox1.Items.Add(item);
}
for (int i = 50; i < 500; i++)
Unit_Price.Add(i.ToString("$#,##0.00"));
foreach (string item in Unit_Price)
{
comboBox2.Items.Add(item);
}
}
int firstvalue;
bool t;
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if(int.TryParse(comboBox1.Text, out firstvalue))
{
t = true;
}
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
if(double.TryParse(comboBox2.Text, currencyStyle, numberFormat, out var secondvalue)&&t)
{
double Result_ = firstvalue*secondvalue;
comboBox3.Items.Add(Result_.ToString("$#,##0.00"));
}
}
}
Result:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.