简体   繁体   English

根据组合框 c# 的选择,我的代码没有切换到所需的 function

[英]My code is not switching to the desired function depending upon the selection from combo box c#

The code is not invoking the show_auto function even though I have selected the CHEMICAL from the drop down, it is always invoking the show_cement function.即使我从下拉列表中选择了 CHEMICAL,代码也没有调用 show_auto function,它总是调用 show_cement function。

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;

and then compare with "CHEMICAL"然后与“化学”比较

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 根据C#中组合框选择中的字符串存储整数 - Store an integer based on a string from a combo box selection in C# 如何根据我的第一个组合框的选择绑定以下列表框 - How to bind the following listboxes depending on the selection of my first combo box 根据C#中datagridview中组合框的值从SQL Server检索数据 - retrieve data from SQL server depending on value of combo box in datagridview in c# C#使用仅1个选择的txt文件中的值填充2个组合框和1个文本框 - C# populating 2 combo boxes and 1 text box with values from a txt file with only 1 selection C#Windows窗体如何根据第一个组合框中的选择更改第二个组合框的值 - C# Windows Forms how to change values of second combo box based on selection in first combo box C#从方法填充组合框 - C# populate a combo box from a method 使用选定值(C#WPF)时,组合框选择已更改事件在选择更改之前触发 - Combo Box Selection Changed Event fires before Selection Changes when using Selected Value (C# WPF) 选择特定项目时移除组合框项目 - Combo box items removal upon selection of a particular item 选择组合框后,将所有匹配的值返回到列表框 - Return all matching values to a listbox upon combo box selection 为什么单击退出时我的C#代码在消息框中出现零? - Why is my C# code coming up with zero's in message box upon clicking exit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM