我有8个comboboxes
,如果用户更改combobox
值中的任何一个,我必须启用一个按钮。
我为每个组合框添加了SelectedIndexChanged
事件。并尝试像这样检查。
if (
cmbDInput_SelectedIndexChanged || cmbSwitch_SelectedIndexChanged ||
cmbSatName_SelectedIndexChanged || cmbDRepeat_SelectedIndexChanged ||
cmbSeq_SelectedIndexChanged
)
但它会抛出错误
运算符
||
无法应用于“方法组”和“方法组”类型的操作数
有任何建议怎么做?
答案 0 :(得分:0)
如果语句表达式cmbDInput_SelectedIndexChanged
运算符应该应用于布尔值,那么您正在使用方法名称,即事件||
。
if ((cmbDInput_SelectedIndexChanged) || cmbSwitch_SelectedIndexChanged || cmbSatName_SelectedIndexChanged || cmbDRepeat_SelectedIndexChanged || cmbSeq_SelectedIndexChanged)
将是
if ((cmbDInput.SelectedIndex !- -1) || cmbSwitch.SelectedIndex != -1|| cmbSatName.SelectedIndex !- -1 || cmbDRepeat_.SelectedIndex != -1 || cmbSeq.SelectedIndex != -1)
或者你可以得到事件的来源,即所选索引的组合如下改变
protected void cmbDInput_SelectedIndexChanged(object sender, System.EventArgs e)
{
ComboBox ChangedCombox = sender as ComboBox;
}