Following is the code to populate combobox using DataSource
Dim CountryList As Array = MyCtrl.GetAllCountries
With cbCountyList
.DataSource = CountryList
.DisplayMember = "CountryName"
.ValueMember = "CountryID"
End With
After adding a new COuntry Name to Database I want to reflect the changes in combobox. Repeating this code is not an option becasue it triggers SelectIndexChange event and had to do some crappy work around to avoid that.
So I was wondering if there is way to refresh the combobox list. I actually thought binding with the DataSource property supposed to do it automatically. I also tried
cbCountyList.Refresh()
Thanks in advance.
You should make a
BindingSourcesit inbetween the ComboBox and your DataSource. Then callBindingSource.ResetBindings(false). It will do all the magic for you.Here is what I mean (in C#, but same idea):