How to rebind a datasource to a ComboBox?

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

Hello,

The first time I bind an array to a ComboBox, it works fine. But when I try
to rebind to the ComboBox, it fails. I tried code like:
this.BookList.DataBindings.Clear();

and
this.BookList.DataSource = null;
this.BookList.Refresh();

No luck so far. I don't get any error; just that the ComboBox becomes empty.

Thanks.
 
Hi Michael,

For rebinding, do the following

1) set the combobox's datasource to nothing or null
combobox1.datasource = null;

2) attach your modified datasource again
combobox1.datasource = myarray;

Does this help ?

Kalpesh
 
Hi Kalpesh,

Thanks for your suggestions. I had set the Sorted property on the combobox
to true. It turns out, I only had to set it to false for the rebinding to
work. Seems like a .NET bug to me. I didn't even have to set my datasource
to null.

If someone can explain if this is a bug or "by design", please let me know.
I'm curious.

Thanks.
Michael
 
Back
Top