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

The Archive Base Latest Questions

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

I want a user to select a value from a ComboBox. Entries have to

  • 0

I want a user to select a value from a ComboBox. Entries have to be suggested at user’s text input.

Do I have to use events to enforce a System.Windows.Forms.ComboBox to contain a value from its own DataSource?

Example: Entries have to be suggested to the user… If I write “CO”, the combo should suggest “CONGO” and “COLOMBIA”, but only one of those values should be entered by the user. The user should not introduce “COfdfgdfg” or any random string.

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

    You have to use combobox.autocompletemode to get the names liek Congo,congress when the user enter the text like “CO”

    you can your own datasource to comboBox1.AutoCompleteSource

     this.comboBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
    this.comboBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
    this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    this.comboBox1.FormattingEnabled = true;
    this.comboBox1.Location = new System.Drawing.Point(113, 192);
     this.comboBox1.Name = "comboBox1";
    this.comboBox1.Size = new System.Drawing.Size(121, 20);
    

    Then populate the combox items source with objects like, that override the ToString method

    public class POCLRO
    {
      public int ID { get; set; }
      public string Name { get; set; }
    
      public override string ToString()
      {
        return Name;
      }
    }
    

    Edit: You have to do validation on text entered by the user in combobox , if the user selects the drop down item suggested by auto completemode the validation returns true else it returns false …

    Do something like below …

    Create a KeyDown event handler for the combobox and check for an Enter key. Note that after the user hits enter the text in the combobox is selected (as in, selected as if you were doing a cut or copy operation) and focus remains in the combobox.

    If enter was pressed call a validation function that will do whatever you feel necessary if the value entered is equal with name that was stored in database…

    You can call this same function in a Leave event handler to prevent the user from leaving the combobox until a valid selection is made.

     private void ComboBox_KeyDown(object sender, KeyEventArgs e)
     {
        if (e.KeyCode == Keys.Enter)
        {
            ValidateSelection();
        }
     }
    
     private  bool validation()
     {
       // do validation here 
     }
    private void ComboBox_Leave(object sender, EventArgs e)
    {
        if(!ValidateSelection())
        {
            ComboBox.Focus();
        }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to let the user select a value from a combo box, and
Hi i want to get changed text value from JQuery but i can't select
I want to use jquery draggable/droppable to let the user select a group of
i have list of rows that user select and i want to delete them,
I want to enable the user to select a video file from the on-device
I want the user to click the select box and when have selected any
I have a user that want to be able to select a textbox and
I have an Excel2010 VBA userform that has one comboBox, from which the user
I have a dropdown on page when user selects any value from it ;
I have made a combobox for a web page. It takes values from user

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.