简体   繁体   English

Combobox 中的项目已添加

[英]Items in Combobox gets added

I've two radiobuttons and a single checkbox.我有两个单选按钮和一个复选框。

Items in checkbox will pop up according to the radiobutton selected.复选框中的项目将根据选择的单选按钮弹出。

The problem is when I click the second radiobutton after clicking the first radiobutton, Combobox pops us all the values from both radiobutton 1 and 2.问题是,当我在单击第一个单选按钮后单击第二个单选按钮时,Combobox 会弹出单选按钮 1 和 2 中的所有值。

    private void radioButton1_CheckedChanged(object sender, EventArgs e)
    {
        foreach (string apacservers in Properties.Settings.Default.B)
        {             
            comboBox1.Items.Add(ItemsB);
        }                    
    }

    private void radioButton2_CheckedChanged(object sender, EventArgs e)
    {
        foreach (string europeservers in Properties.Settings.Default.A)
        {               
            comboBox1.Items.Add(ItemsA);
        }               
    }

Any help would be much appreciated任何帮助将非常感激

you need to add comboBox1.Items.Clear();你需要添加comboBox1.Items.Clear(); before both of your foreachs.在你的两个前锋之前。

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

相关问题 将组合框中添加的项目保存到文件 - Saving added items in a combobox to a file 带有添加的 MRU 项的 WPF 组合框 - WPF combobox with added MRU items C#保存添加到组合框的项目 - C# saving items added to combobox 如何在会话之间将添加的项目保存到 combobox? - How to save added items to combobox between sessions? 在运行时添加到ListBox的项目永远不会集中精力 - Items added to the ListBox at runtime never gets focused 为什么WPF组合框itemssource转换器获取整个集合而不是项目? - why WPF combobox itemssource converter gets whole collection and not items? 添加项目后,C# ComboBox SelectedIndex 始终为 0 - C# ComboBox SelectedIndex is always at 0 once Items are added 从ASPX页面手动将项目添加到组合框,以及从代码隐藏添加的项目 - Adding Items to Combobox manually from aspx page ,along with items added from codebehind 动态地在组合框中添加项目,并且用户添加的项目应该是永久的而不使用数据库,这可能吗? - Adding items in the combobox dynamically and items added by user should be permanent without using database,is possible? 最初将ComboBox绑定到具有0个项目的数据源,后来添加的项目会导致ArgumentOutOfRangeException - Binding ComboBox to data source with 0 items initially, items added later causes ArgumentOutOfRangeException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM