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


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
 
Ad

Advertisements


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