-
ComboBox Behavior
I have a combo box on a standard windows form. The combo box is bound to a field from Access table1. The Display Member is a field from the data source table. There is another field from the data source table that is the Value Member. It was my understanding that when the form is run the combo box would display a list of values (from the Display Member field) to select from (the combo box does this). It was also my understanding that the value placed in the bound field would be the value from the Value Member field (it does not do this). It actually inputs the Display Member field value. What am I doing wrong here?
-
Re: ComboBox Behavior
At a guess, I'd say that you're using the Text property of the ComboBox, which will return the text displayed in the control, which obviously comes from the property/column specified by the DisplayMember. If you want the value from the property/column specified by the ValueMember then you have to use the SelectedValue property of the ComboBox.
If I've guessed wrongly then you're going to have to actually show us what you're doing rather than describing what you think you're doing.
-
1 Attachment(s)
Re: ComboBox Behavior
Here is the data properties for the combobox:
Attachment 124969
fieldA from tableA is binding source. TableB is the Datasource, Field1 TableB is the DisplayMember, and Field2 TableB is the ValueMember
What I was expecting was the Field2 TableB value to be placed in the fieldA tableA value.
-
Re: ComboBox Behavior
It's exactly as I said. As you can see from the (DataBindings) section of your properties window, you have bound the Text property rather than the SelectedValue property. Remove the existing binding and add a new binding on the correct property and you'll be good to go.