Synchronised ComboBoxes

  • Thread starter Thread starter Doug Bell
  • Start date Start date
D

Doug Bell

Hi,
I have a "Settings" form with a number of Combo Boxes.

Several of these Combos have their DataSource set to an ArrayList.
I have found that changing the selected text for one combo also changes the
other combo boxes displayed text.

Why does this happen?
Do I need to create a separate ArrayList for each Combo?

Thanks Doug
 
Hi,

Doug Bell said:
Hi,
I have a "Settings" form with a number of Combo Boxes.

Several of these Combos have their DataSource set to an ArrayList.
I have found that changing the selected text for one combo also changes
the
other combo boxes displayed text.

Why does this happen?

By default controls use their parent's BindingContext. If the
BindingContext, DataSource and DataMember are the same, then the same
CurrencyManager will be used which mantains the position.
Do I need to create a separate ArrayList for each Combo?

You can, but an alternative is to create a new BindingContext for each
ComboBox preferably before binding:

Dim someList As New ArrayList
' ....
'.....
comboBox1.BindingContext = new BindingContext
comboBox1.DataSource = someList

comboBox2.BindingContext = new BindingContext
comboBox2.DataSource = someList


HTH,
Greetings
 
Doug,

No it is easier to use a datatable. That has his own defaultview, however
you can add as much seperated new dataviews as you want.

I hope this helps,

Cor
 
Hi Bart,

Thanks. Works great!

Bart Mermuys said:
Hi,



By default controls use their parent's BindingContext. If the
BindingContext, DataSource and DataMember are the same, then the same
CurrencyManager will be used which mantains the position.


You can, but an alternative is to create a new BindingContext for each
ComboBox preferably before binding:

Dim someList As New ArrayList
' ....
'.....
comboBox1.BindingContext = new BindingContext
comboBox1.DataSource = someList

comboBox2.BindingContext = new BindingContext
comboBox2.DataSource = someList


HTH,
Greetings
 
Cor Thanks,
I could have constructed a DataTable but it was easier to build an Array
list as I had 18 Combos with 8 different sets of data that each needed a
first row added ("Select xxxx") to the original DataTables and the original
DataTables were required in tact.

So I built a function to create the 8 different array lists.

Bart answered my question explaining about the inheritance of the Currency
manager.

Doug
 
Back
Top