All comboboxes automatically changing when user changes only one ???

A

Alex

Hi,

I have a strange question... I have a series of combo boxes being
populated by the same dataset, and I've noticed if one is changed then
all change as well. I'm using Visual Basic 2005 and writing a Winform
app, and below is how I'm binding the dataset to the combobox object:

cbTotalCurrency.DataSource = CurrencyDataset.Tables(0)
cbTotalCurrency.DisplayMember = "CurrencyName"
cbTotalCurrency.ValueMember = "CurrencyID"

I have about 5 comboboxes using this same dataset and if I change any
of the dropdowns in the application when running, all 5 change to
whichever one I selected.

Other than creating 5 different datasets, is there anyway around
this? I want the user to be able to select a different item in each
combobox.

Thanks --

Alex
 
K

Kerry Moorman

Alex,

One way to make the comboboxes independent of each other is to assign each
combobox a new binding context. For example:

cbTotalCurrency.BindingContext = New BindingContext
cbTotalCurrency.DataSource = CurrencyDataset.Tables(0)
cbTotalCurrency.DisplayMember = "CurrencyName"
cbTotalCurrency.ValueMember = "CurrencyID"

Do that for each of the comboboxes and then they should be independent.

Kerry Moorman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top