[英]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.