Home All Groups Group Topic Archive Search About

combobox binding problem

Author
27 Apr 2006 2:34 PM
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.

Author
27 Apr 2006 6:57 PM
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.

Show quote
"Fanor" <xreed2***@yahoo.com> wrote in message
news:uYGaKcgaGHA.3812@TK2MSFTNGP04.phx.gbl...
>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.
>
>
>
Author
27 Apr 2006 10:13 PM
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.

Show quote
"Andrew Oliner" <andyo@me.oliner.nospamhere.com> wrote in message
news:OiRpjxiaGHA.996@TK2MSFTNGP04.phx.gbl...
> 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.
>
> "Fanor" <xreed2***@yahoo.com> wrote in message
> news:uYGaKcgaGHA.3812@TK2MSFTNGP04.phx.gbl...
>>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.
>>
>>
>>
>
>
Author
28 Apr 2006 1:46 AM
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.

Show quote
"Fanor" <xreed2***@yahoo.com> wrote in message
news:uYGaKcgaGHA.3812@TK2MSFTNGP04.phx.gbl...
>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.
>
>
>

AddThis Social Bookmark Button