C# 如何在windows应用程序的组合框中动态添加值

C# 如何在windows应用程序的组合框中动态添加值,c#,C#,我有一个两个组合框。我想将第一个组合框中未选择的值动态添加到第二个组合框中 Dictionarytest=newdictionary(); Dictionary<string, string>test = new Dictionary<string, string>(); test.Add("1", "dfdfdf"); test.Add("2", "dfdfdf"); test.Add("3", "dfdfdf");

我有一个两个组合框。我想将第一个组合框中未选择的值动态添加到第二个组合框中

Dictionarytest=newdictionary();
Dictionary<string, string>test = new Dictionary<string, string>();
        test.Add("1", "dfdfdf");
        test.Add("2", "dfdfdf");
        test.Add("3", "dfdfdf");
        comboBox1.DataSource = new BindingSource(test, null);
        comboBox1.DisplayMember = "Value";
        comboBox1.ValueMember = "Key";

// Get combobox selection (in handler)
string value = ((KeyValuePair<string, string>)comboBox1.SelectedItem).Value;
测试。添加(“1”、“dfdfdf”); 测试。添加(“2”,“dfdfdf”); 测试。添加(“3”,“dfdfdf”); comboBox1.DataSource=新的BindingSource(测试,null); comboBox1.DisplayMember=“值”; comboBox1.ValueMember=“Key”; //获取组合框选择(在处理程序中) 字符串值=((KeyValuePair)comboBox1.SelectedItem).value;
那么问题出在哪里?(提示,使用两个临时列表)只需使用selection changed事件,获取组合框中的所有项目,并删除已选择的项目。这不会回答问题,它会删除附加到列表项目的任何对象。不要只是复制并通过代码,而是放置链接