Avatar of Olukayode Oluwole
Olukayode Oluwole
Flag for Canada asked on

How do i get a field from a combo box

I have a c# application in which i need to get a field from a combo box.

See a table which i have loaded into a combo . (See table below)

Loaded Table with Data
What i want to grab are 2 fields  othercurrencycode   and  exchrate

Below is the script that does the Load and specifies the 2 fields  to get

  LoginDetails.exDataSource = GlobalConfig.Connection.GetExchRate_All();
  glTRANSCurrencyValue.DataSource = LoginDetails.exDataSource;
  glTRANSCurrencyValue.DisplayMember = "FullCodeName";
  glTRANSExchrateValue.DataBindings.Add(new System.Windows.Forms.Binding("Text", LoginDetails.exDataSource, "exchrate", true));
  glTRANSCurrencyValue.DataBindings.Add(new System.Windows.Forms.Binding("Text", LoginDetails.exDataSource, "othercurrencycode", true));

Below is short of the screen that shows the loaded Combo

Combo Load Display
The screen below shows that the Currency instaed is showing the ValueMember is showing the DisplayValue (see below)

Currecycode value showing display member instead of Valuemember
what do i need to specify to get the USD  as the code at runtime and not the complete record

Thanks

Oluaky
C#

Avatar of undefined
Last Comment
Olukayode Oluwole

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Rikin Shah

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.
dejaanbu

As in the previous expert comment, not sure how you're using the objects..

If glTRANSCurrencyValue is your combobox id..

You are setting glTRANSCurrencyValue
DisplayMember,.. similarly

 try setting the currency code column result to
glTRANSCurrencyValue.ValueMember
Olukayode Oluwole

ASKER
Thanks Got it
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy