从字符串数组填充的组合框是重复的

时间:2018-01-25 16:04:58

标签: c# combobox

我的组合框正确填充,但是当我在4个框中的1个框中选择一个值时,所有框都采用相同的值。

culturesListNames是来自txt文件的信息,我想申请4个组合框

我的代码:

String[] culturesListNames1 = new String[300];
String[] culturesListNames2 = new String[300];
String[] culturesListNames3 = new String[300];
String[] culturesListNames4 = new String[300];

culturesListNames1 = culturesListNames;
culturesListNames2 = culturesListNames;
culturesListNames3 = culturesListNames;
culturesListNames4 = culturesListNames;

BindingSource theBindingSource1 = new BindingSource();
theBindingSource1.DataSource = culturesListNames1;

BindingSource theBindingSource2 = new BindingSource();
theBindingSource2.DataSource = culturesListNames2;

BindingSource theBindingSource3 = new BindingSource();
theBindingSource3.DataSource = culturesListNames3;

BindingSource theBindingSource4 = new BindingSource();
theBindingSource4.DataSource = culturesListNames4;

comboBox1.DataSource = theBindingSource1.DataSource;
comboBox2.DataSource = theBindingSource2.DataSource;
comboBox3.DataSource = theBindingSource3.DataSource;
comboBox4.DataSource = theBindingSource4.DataSource;`

1 个答案:

答案 0 :(得分:0)

问题由Wheels73和Michael定义。您必须复制数据或将其复制如下:

enter image description here enter image description here