根据从组合框 c# 中的选择,我的代码没有切换到所需的功能
My code is not switching to the desired function depending upon the selection from combo box c#
即使我从下拉列表中选择了 CHEMICAL,代码也没有调用 show_auto 函数,它总是调用 show_cement 函数。
private void gunaComboBox1_SelectedIndexChanged(object sender, EventArgs e) {
ArrayList companyName = new ArrayList();
ArrayList Price = new ArrayList();
ArrayList category = new ArrayList();
String selected = this.gunaComboBox1.GetItemText(this.gunaComboBox1.SelectedItem);
if (selected.Equals("CHEMICAL")) {
show_auto(companyName, Price, selected);
} else {
show_cement(companyName, Price, "CEMENT");
}
}
String selected = gunaComboBox1.selecteditem.text;
然后与“CHEMICAL”比较
即使我从下拉列表中选择了 CHEMICAL,代码也没有调用 show_auto 函数,它总是调用 show_cement 函数。
private void gunaComboBox1_SelectedIndexChanged(object sender, EventArgs e) {
ArrayList companyName = new ArrayList();
ArrayList Price = new ArrayList();
ArrayList category = new ArrayList();
String selected = this.gunaComboBox1.GetItemText(this.gunaComboBox1.SelectedItem);
if (selected.Equals("CHEMICAL")) {
show_auto(companyName, Price, selected);
} else {
show_cement(companyName, Price, "CEMENT");
}
}
String selected = gunaComboBox1.selecteditem.text;
然后与“CHEMICAL”比较