我正在做一个服装店程序,我的代码是这样的。
cbmale.Items.Add(new Data { Name = "Male Shirt", Value = "10.0f" });
cbmale.Items.Add(new Data { Name = "Male Jeans", Value = "20.0f" });
cbmale.Items.Add(new Data { Name = "Male Pants", Value = "20.0f" });
cbmale.Items.Add(new Data { Name = "Male Socks", Value = "20.0f" });
cbmale.Items.Add(new Data { Name = "Male Hoodie", Value = "20.0f" });
cbmale.DisplayMember = "Name";
cbmale.ValueMember = "Value";
private void button1_Click(object sender, EventArgs e)
{
int quantity = (int)nudmale.Value;
bool isRBchecked = rbsmallmale.Checked || rbmediummale.Checked || rblargemale.Checked;
if (isRBchecked == false)
{
MessageBox.Show("Please select a size of the selected male item");
totalpricemale = 0.0f;
}
if (string.IsNullOrEmpty(cbmale.Text))
{
MessageBox.Show("No Item is Selected");
}
else
{
MessageBox.Show("Item Selected is:" + cbmale.Text);
}
totalpricemale = totalpricemale + quantity *
lblmale.Text = totalpricemale.ToString("C");
}
那么如何使用我插入的值来计算所选项目的总价格?现在我的计算公式是这个 totalpricemale = totalpricemale + quantity 那么我如何在这个公式中包含这个值呢?