combobox binding problem

F

Fanor

I have a combo box bound to a binding source wich is bound to a table. For
some reason the selectedvalue of the combo box doesn't show the correctt
value of the row the first time the form is showed. When I move to the next
row using a binding navigator the combobox selectedvalue have the correct
value and come back to the first record and it shows the correct value.

For instance if the field value is 2, the combobox selectedvalue is 0, it
looks that the binding is not working yet.
I tried using combobox.refresh() and changinng bindingsource.position on
the form_load and still doesn't work.


I also have other forms using combo box and they work without any problem.

I have setup displaymember and value member.

Any help is very appreciated.
 
A

Andrew Oliner

I'm having the same problem. I haven't really dug into it yet, but I'm
worried that it's this:
http://www.jelovic.com/weblog/e107.htm

If it is, he lists this bug as still unfixed.

Ok, poking around a little more got me this:

Can be fixed by binding a ComboBox to the SelectedItem property instead
of the Text property. For example:
cboTest.DataBindings.Add("SelectedItem", dsTest, "MyTable.MyColumn");

Haven't had a chance to try it yet.
 
A

Andrew Oliner

I was wrong. I was not having this issue at all. I had a line in my
form_load which read

myCombo.text = ""

The intent was to have a new record show a blank in the Combo, but it was
getting called every time the form displayed the first record.
 
F

fanor

I solved this problem, in form_load I changed by code the selectedindex of
the combobox, because in this case the valuemember is zero based.
 

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