我有我的代码的问题,我想在总金额总结后显示更改,用户从ComboBox
中挑选一张钞票,但我不确定我是否正在使用正确的事件处理程序/触发器功能如果我应该做这些转换。我得到的错误是:我应该使用哪种ComboBox事件处理程序?
Error 2 The event 'System.Windows.Forms.ComboBox.SelectedIndexChanged' can only appear on the left hand side of += or -= J:\EDPtest1\EDPtest1\Form1.cs 100 49 EDPtest1
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (Convert.ToDouble(comboBox1.SelectedIndexChanged == total))
{
lblChange.Text = "Amount Correct";
}
else if (Convert.ToDouble(comboBox1.SelectedIndexChanged > total))
{
lblChange.Text = "Total change: " + comboBox1.SelectedIndexChanged - total;
}
else if(Convert.ToDouble(comboBox1.SelectedIndexChanged < total))
{
lblChange.Text = "Please add more money";
}
}
[ComboBox.SelectedItem地产(https://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selecteditem( v = vs.110).aspx) –
我试过了,但它不起作用,因为它告诉我操作符''不能应用于类型'objects'和'double'的操作数 –
'(Convert.ToDouble( comboBox1.SelectedItem)== total)'< - 注意parens。你的地方错了。 –