Link to home
Start Free TrialLog in
Avatar of SamB
SamB

asked on

Combobox DisplayMember & ValueMember Understanding

Hi Experts,

I'm not sure if I understand the meaning of displaymember and valuemember correctly on combobox's but in relation to my MS Access experience, I understand the first is what's displayed in the combobox and the second is what value is used when a selection is made?

I have a windows form that has a bound combobox on it and I have set the datasource to a seperate table which stores the combobox list. I then set the displaymember (and this a string (it's a name)) and the valuemember (which is a unique integer).

This shows the displaymember as required and I can select from the list - but when I attempt to move onto the next record in my dataset it will not. I assume it won't accept the string in the combobox - as it's bound to a field of integer type - and is attempting to store this integer not the valuemember string?

Not sure how well I've explained that!

Any assistance, as usual much appreciated.

Best regards,

Sam
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SamB
SamB

ASKER

Hi jpaulino,

Here's my code:
     
Me.DmComboBox.DataSource = Me.MasterDataSet1.DMP
Me.DmComboBox.DisplayMember = "dmpsupplier"
Me.DmComboBox.ValueMember = "id"

Me.DmComboBox.SelectedIndex = 1

I've added the selectedindex and changed it from 0 to 1 but no luck - still populates the combobox with the string, but won't allow any changes. I've also noticed that I can scroll through records if I don't touch this combobox, but all the values are showing as the first in the list (which is not correct).

Many thanks,

Sam

But you see the values ?
Avatar of SamB

ASKER

Yes - I see the values (strings) but as soon as I attempt to select one the form 'locks up' because it seems not to like my selection.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SamB

ASKER

Thanks Guys - it was a combination of the two answers.