Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7693951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:12:26+00:00 2026-05-31T21:12:26+00:00

I have table with 4 primary key fields. I load that in to drop

  • 0

I have table with 4 primary key fields. I load that in to drop down list in my WinForm application created by using C#.

On the TextChanged event of drop down list I have certain TextBox and I want to fill the information recived by the table for the certain field I selected by the drop down list.

So as I say the table having 4 fields. Can I get those all 4 fields into value member from the data set, or could you please tell me whether is that not possible?

Thank you.

Datatable dt=dba.getName();
cmb_name.ValueMember="id";
cmb_name.DisplayMember="name";
cmb_name.DataSource=dt;

this is normal format.. but i have more key fields.. so i need to add more key fields..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:12:27+00:00Added an answer on May 31, 2026 at 9:12 pm

    You can use DataSource property to bind your source data to the ComboBox (e.g. a List of Entities, or a DataTable, etc), and then set the DisplayMember property of the ComboBox to the (string) name of the field you want to display.

    After the user has selected an Item, you can then cast the SelectedItem back to the original row data type (Entity, DataRow, etc – it will still be the same type as you put in), and then you can retrieve your 4 composite keys to the original item.

    This way you avoid the SelectedValue problem entirely.

    Edit:

    Populate as follows:

    cmb_name.DisplayMember = "name";
    cmb_name.DataSource = dt;
    
    // Ignore ValueMember and Selected Value entirely
    

    When you want to retrieve the selected item

    var selectedRow = (cmb_name.SelectedItem as DataRowView );
    

    Now you can retrieve the 4 values of your PK, e.g. selectedRow["field1"], selectedRow["field2"], selectedRow["field3"] etc

    If however you mean that you want to DISPLAY 4 columns to the user (i.e. nothing to do with your Table Key), then see here How do I bind a ComboBox so the displaymember is concat of 2 fields of source datatable?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with 3 fields: ID (not unique, not primary key) timestamp
I have a database table and one of the fields (not the primary key)
Suppose you have these tables: Table Name: Salesman Fields: S_ID(Primary Key), Name Table Name:
I have a table containing primary key and foreign key that references same table.
I have a table with a primary key that is auto increment. I want
I have table A in Oracle that has a primary key (id). I need
I have a table with the following fields: id VARCHAR(32) PRIMARY KEY, parent VARCHAR(32),
I have a MySQL table with a primary key field that has AUTO_INCREMENT on.
I have table that doesn't need a specific field to be the primary key.
I have a table which have 4 fields. Col1 Guid Primary-Key (FK to another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.