Avatar of FCapo
FCapo
 asked on

vb.net Combobox Binding

Hi,

is there a way to have a combobox that fills its list with data from a different column but saves the selection binding to another column?

Say I have a column A with no values, and another column B with all the choices, can I tell the combobox to get its items from B and then save the user selection to column A
Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
Ark

8/22/2022 - Mon
Russ Suter

Comboboxes don't have columns. I'm not sure what you're getting at here.
FCapo

ASKER
Sorry I meant a field in a database table
Scott McDaniel (EE MVE )

If your combo is bound, then bind it to ColumnA, but use ColumnB when building the Datasource for the Combo.
Your help has saved me hundreds of hours of internet surfing.
fblack61
FCapo

ASKER
ok great,

for the code I currently have this,

soumissionNumber.DataBindings.Add("text", soumissionBindingSource, "ColumnA")

How could I incorporate columnB Scott?
ASKER CERTIFIED SOLUTION
Jacques Bourgeois (James Burger)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Ark

Strange solution to have 2 same columns. IMHO better have TABLE B with all choices and TABLE A with column A binded to ID field of TABLE B. In this case you can fill combo using TABLE B as datasource, ID field as ValueMember and TextField as DisplayMember, like James suggesting.