All comboxes display the same item. Why?

I have created 10 comboxes on one form and they all get their list from an array -

Form1.ComboBox1.DataSource = string_array

What is happens is that when I select an item in combobox1 all the other comboboxes automatically display the same thing. Why?

My other comboboxes are also set to get their data from the same array. but if I make them take data from another identical array same thing happens. Why?
cdseteamOperations Manager - End User ComputingAsked:
Who is Participating?
VeryNiceManConnect With a Mentor Commented:

your solution will work ONLY in web pages; and it will fail on Windows Forms.
explaining why; will need long pages and pages. if you want to know why this happen then i will try to find some websites that explains this behaviour.

the solution without explaining why is as follows:

 Private Sub Form9_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a() As String = New String() {"a", "b", "c", "d", "e", "f"}

        ComboBox1.BindingContext = New BindingContext
        ComboBox1.DataSource = a

        ComboBox2.BindingContext = New BindingContext
        ComboBox2.DataSource = a

        ComboBox3.BindingContext = New BindingContext
        ComboBox3.DataSource = a

        ComboBox4.BindingContext = New BindingContext
        ComboBox4.DataSource = a

        ComboBox5.BindingContext = New BindingContext
        ComboBox5.DataSource = a

        ComboBox6.BindingContext = New BindingContext
        ComboBox6.DataSource = a
    End Sub

the above will work for ANY number of ComboBox on your form; just keep adding they; you can also try to put the whole thing in a loop or whatever you like.

hope that helps;
best regards;
How about posting the smalles code sample which shows the mentioned behaviour?


Just verify whether the onchange event is same for all the comboboxes..??

If u r using html control..just verify the onchange event in their html tag..

What needs to be done is to create a separate Datasource for each combobox, then you will have 10 separate "views".  
cdseteamOperations Manager - End User ComputingAuthor Commented:
Thanks. You sent me in the right direction...

I went to and found some more info which helped me.

"If you have two controls bound to the same datasource, and you do not want them to share the same position, then you must make sure that the BindingContext member of one control differs from the BindingContext member of the other control. If they have the same BindingContext, they will share the same position in the datasource.

If you add for example a ComboBox and a ListBox to a form, the default behavior is for the BindingContext member of each of the two controls to be set to the Form's BindingContext. Thus, the default behavior is for the ListBox and ComboBox to share the same BindingContext, and hence the selection in the ComboBox is synchronized with the current row of the ListBox. If you do not want this behavior, you should create a new BindingContext member for at least one of the controls."
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.