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 6688733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:26:15+00:00 2026-05-26T05:26:15+00:00

I have an editable ComboBox with a validation on the Text property to make

  • 0

I have an editable ComboBox with a validation on the Text property to make sure manually entered info is valid.

EDIT: All I want to do is populate the .Text property with the ValueMember of a selection rather than the DisplayMember

I also have the .Items populated with valid entries having the DisplayMember and ValueMember set.

My DisplayMember is a caption along with the data, and the ValueMember is the data itself.

So Items might be:

(DisplayMember, ValueMember)
"Foo - 1ab2"  , "1ab2"
"Bar - 3cd4"  , "3cd4"

I had a validation on the text which can also validate manual user input like “5ef6”

The problem I’m having is that if the user selects an item from the combobox it populates the text field with the DisplayMember property (ex: “Foo – 1ab2”) which will fail validation.

I have tried to manually set the .Text property with the SelectedValue or the SelectedItem.Value on each of the three relevant combobox events to no avail.

I would like that the .Text of the ComboBox get populated with the .ValueMember of the item when selected rather than the .DisplayMember

EDIT: I cannot validate by trying to extrapolate the value from the caption. I send the Text off to a service to be validated.

void FillMyCombo
{
    KeyValuePair<string, string> listValue1 = new KeyValuePair<string, string>("Foo - 1ab2"  , "1ab2")
    KeyValuePair<string, string> listValue2 = new KeyValuePair<string, string>("Bar - 3cd4"  , "3cd4")
    myCombo.Items.Add(listValue1);
    myCombo.Items.Add(listValue2);

    myCombo.DisplayMember = "Key";
    myCombo.ValueMember = "Value";
}

...

void myCombo_TextUpdated
{
    if(!myValidationService.Validate(myCombo.Text))
    {
        do error stuff
    }
}

The user can manually enter something like “5ef6” which will pass validation.
But when they select an item from the list, rather than manually entering it, the .Text property gets filled with the caption and not the value … so it will contain “Foo – 1ab2” and that will fail validation.

EDIT: In response to an answer posted: I cannot change the validation method to “infer” the value from the caption. I have no control over that service. All I’m after is the displayed value

EDIT: Say a user selects “Foo – 1ab2” from the dropdown list, I want the text in the box to say “1ab2”

EDIT: I have also tried to set the .Text property in code but I can’t seem to make it work in any of the ComboBox events. If anybody can answer how to programmaticly set the .Text property (and make it commit!) on a selection event they will also answer this question.

  • 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-26T05:26:15+00:00Added an answer on May 26, 2026 at 5:26 am

    What about http://nickstips.wordpress.com/2010/11/19/c-datagridviewcomboboxcolumn-displaying-different-values-in-drop-down-list/ — they change ValueMember and DisplayMember on the fly upon dropdown opening/closing.

    Example is for DatagridViewComboBox. A ComboBox has those events, too, no?

    Give it a try and downvote if it does not help :)=

    ** Update **

    Another good-looking solution might be ArgumentException when adding ComboBox column to DataGridView with same DataSource, there look at the not-accepted answer.

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

Sidebar

Related Questions

I have a Tix.ComboBox with an editable text field. How do I force the
I have an editable ComboBox component and I want to reference the TextInput that
I have an editable mx:Combobox . I want to catch two events: When a
I have a Listbox where all cells are editable. While the user is typing
I have a simple table view which is editable. All I need the user
I have an editable WPF ComboBox with TextSearchEnabled. I need to force the user's
I have a problem with AutoCompleteBox. I wanted to use it as editable combobox.
I have a combobox and it's editable. So the user can select an item,
I have an ExtJS combobox with a remote data store behind it. In all
I have editable combobox where not always the preferred item is in the drop-down

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.