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

  • Home
  • SEARCH
  • 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 8958733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:16:57+00:00 2026-06-15T15:16:57+00:00

The situation is that I have 2 controls, a text box and a combo

  • 0

The situation is that I have 2 controls, a text box and a combo box. The user can select something in the combo box, it fills the text box with the value member, if the user types into the text box, I want to check if it exists in the combo box’s values and then select the corresponding display member.

The method I was expecting to be there was something like

if(cmb1.valueMembers.Contains(txt1.Text))

but I can’t find anything like this, I also thought looping through them could find it? so I’ve got

foreach (System.Data.DataRowView row in cmb1.Items)
        {}

but can’t find the value member anywhere in the row?

Thanks

  • 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-06-15T15:16:58+00:00Added an answer on June 15, 2026 at 3:16 pm

    Ok, here’s a simple example but I guess that’s the main idea. We have a MyClass which have Id for the ValueMember and Name for the DisplayMember.

     public partial class Form1 : Form
    {
        class MyClass
        {
            public MyClass(string name, int id)
            {
                Name = name;
                Id = id;
            }
            public string Name { get; set; }
            public int Id { get; set; }
        }
    
        List<MyClass> dsList = new List<MyClass>();
    
        public Form1()
        {
    
            for (int i = 0; i < 10; i++)
            {
                dsList.Add(new MyClass("Name" + i , i));
            }
    
            InitializeComponent();
    
            comboBox1.DataSource = dsList;
            comboBox1.ValueMember = "Id";
            comboBox1.DisplayMember = "Name";
        }
    
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            //Checks if item with the typed Id exists in the DataSource
            // and selects it if it's true
            int typedId = Convert.ToInt32(textBox1.Text);
            bool exist = dsList.Exists(obj => obj.Id == typedId);
            if (exist) comboBox1.SelectedValue = typedId;
    
        }
    
    
        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            MyClass obj = comboBox1.SelectedValue as MyClass;
            if (obj != null) textBox1.Text = obj.Id.ToString();
        }
    }
    

    Feel free to ask if something’s not clear.

    PS: In the example I’m assuming that integers will be typed in the textbox

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

Sidebar

Related Questions

My situation is that I have a video gallery where when a user clicks
I have an situation here that looks very like a SELECT N+1 from the
I have a simple control that has a masked text box: xmlns:extToolkit=http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended ... <extToolkit:MaskedTextBox
I have some user controls in ASP.NET that I am using as simply HTML,
I have a form for that a user fills out and submits. Once submitted
I’m in the situation that I have to design and implement a rather big
I have that situation: I have models Item, Region and Country. class Item(models.Model): name
My situation is that: I have a button that change background of my parent
All, I am new to Windows 7 Phone. My situation is that I have
First, the code: tab_textArea_file.addTab(docLabel, null, scrollPane_textArea, null); So the situation is that I have

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.