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
LVL 1
SamBAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
>> I attempt to move onto the next record in my dataset it will not
Have you tried to change the selectedindex ?

Can you show us what you got ?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SamBAuthor Commented:
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

0
Jorge PaulinoIT Pro/DeveloperCommented:
But you see the values ?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

SamBAuthor Commented:
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.
0
SanclerCommented:
Is this linked to yet another datatable?  That is, are you using this combo to put a value in another record?  Is it a "look-up"?  If so, it sounds as though that other table is expecting one datatype and being offered a different datatype.

Do you have any code anything at all like this

Me.DmComboBox.Bindings.Add("SelectedValue",SomeTable,"SomeFieldName")

If so, can we please see it?

Roger
0
SamBAuthor Commented:
Thanks Guys - it was a combination of the two answers.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.