Jump to content

Combobox text and value

Recommended Posts



I did some search around the form but can't find a answer for my problem.

I fetch some data from a database. Then i want to create a combobox with say "Display name" and when i read the combobox get the ID of the selected "Display name".

Whit other words, the same as HTML  

<select name="user" id="user">
  <option value="25">Hans</option>
  <option value="43">Dik</option>

Is this possible or is there a other control to do that.

Share this post

Link to post
Share on other sites

As far as I know this is not possible with standard ComboBox in Windows (Win32 API) - but not sure at 100%.


But you can use quite simple workaround:

create two arrays: one for IDs and one for Display names

both arrays will have the same index.

After fetching value from ComboBox, find its ID from second array by the same index from first array (here matching by Display name).

Edited by Zedna

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now