void calculate()
{
total = 0.0;
price = 0.0;
calori = 0;
for (int i = 0; i < AdditionsListBox.Items.Count; i++)
{
if (AdditionsListBox.GetItemChecked(i) == true)
{
price = price + pricearray[milkindex * 3 + i];
calori = calori + caloriarray[milkindex * 3 + i];
}
}
total = Convert.ToInt16(numericUpDown5.Value)* price;
totalTextbox.Text = price.ToString();
UnitCaloriTextbox.Text = calori.ToString();
totalTextbox.Text = total.ToString();
}
当我检查时, AdditionsListBox.GetItemChecked(i) 它不是真的,但是当我取消选中项目时,它会给我真的我的错误在哪里?例如,我检查了项目,但它没有计算,但是当我取消选中项目时,它计算正确