databinding combobox to a bindingsource - value of '0' is not valid for 'selectedindex'

  • Thread starter Thread starter BillE
  • Start date Start date
B

BillE

VS2008, vb.net windows forms.

I have a combo box bound to a binding source. The form is created using the
Visual Studio design window.

When I set the datasource for the binding source at run time, it throws an
error:
"value of '0' is not valid for 'selectedindex'"

If instead I set the data source for the combo box at run time, AFTER the
datasource is set for the binding source, like this:

"ComboBox1.DataSource = BindingSource1"

then everything works just fine.

I would prefer to have the datasource for the combo box set at design time -
is there something I'm missing to be able to set the datasource of the combo
box to a binding source at design time, without getting this error?

It is nice to be able to set it an design time, because then I can select
the display and value members from the dropdowns, if the binding source is
bound to a custom object.

Thanks
Bill
 
Back
Top