Click here to Skip to main content
13,256,123 members (35,416 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all experts,

i have one combo box called "Customer Group". This combo box will get all customer group in database from table "CustomerGroup" and in this table it has 2 columns (Code and Name). i want to display "Name" columns in Combo box and when i save it get the "Code" Column to other table(Customer Table).

Does anybody know how to do that?


Posted 7-Aug-12 16:40pm
Wes Aday 7-Aug-12 23:04pm
Yes, I am quite sure that quite a few people know how to do this. Sounds pretty trivial. The question for you is, "What have you tried and what specific problem are you having?". Where is the code that you wrote that demonstrates the problem that you are experiencing? Do you not know how to create a project? Start Visual Studio? Connect to a database? Query a database? Except for, "Does anybody know how to do that?," you didn't even ask any sort or a question or describe any sort of a problem.
soeun tony 8-Aug-12 0:12am
Hi Wes Aday,
i said about combo box.So it means that i already created a project. Have you ever dropped a combo box without created project?. We need to created Project First.Am i right? Here is my query to display customer group "select code,name from customergroup". My question is how can i get the group code when i select group name in combo box?
No, no. There are at least four different but similar types called "ComboBox". Why anyone would try to answer for all cases? Please, be more specific. To start with, exact type name, please.
Member 9496620 14-Aug-15 2:12am
i a using a combobox as in the example in solution 2.
if i write the name i need to select the combobox does not return the 'selectedvalue' value but if i click on the name all works fine. how can i force the combobox to return the selectedvalue in this case ?
thank you.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2


Its simple buddy

Let's say, you have a combo box "ComboCustomerGroup"

dim CustGroupDT as DataTable=GetCustomerGroupNameAndCode()

and when you save the data to your table(Customer Table), use


This will give you the "Code" corresponding to the "Name" of the selected item of your combobox

Hope it works for you
Have a nice code day!!
soeun tony 8-Aug-12 0:21am
Hi a4ashiq,
Your simple is very useful for me. Thank you so much for this posted.

a4ashiq 8-Aug-12 0:25am
You're welcome dude. Rate the answer if it helped you..
Thank you
Volynsky Alex 8-Aug-12 19:13pm
Thanks a4ashiq185!
jabbarpatel 15-Jan-13 7:19am
nice example... thanks
Jessy Pimentera 12-Aug-14 10:43am
Is it possible to have more than one ValueMamber? Or theres another solution for that?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171114.1 | Last Updated 17 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100