答案 0 :(得分:1)
我不知道你如何填充你的组合框,但这里有一个样本,
List<string> items = new List<string>();
private void Form1_Load(object sender, EventArgs e)
{
items.Add("test");
items.Add("asd");
items.Add("qwe");
comboBox1.DataSource = items;
comboBox2.DataSource = items;
}
在Combobox1的selectedIndexChanged
事件中;
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
List<string> values = (List<string>)comboBox2.DataSource;
values = items.Where(x => x != comboBox1.SelectedItem.ToString()).ToList();
comboBox2.DataSource = values;
}
希望有所帮助,