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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:24:21+00:00 2026-05-20T18:24:21+00:00

Just like the title says… I have a Winforms application with a databound dropdown.

  • 0

Just like the title says… I have a Winforms application with a databound dropdown. I want the user to have the convenience to pick from a bunch of predefined values, but also the ability to type in his own value

If I just enable databinding and set dropdown type to anything but DropDownList, it allows me to enter anything I want, but does not persist it to the objects…
Seems like a simple problem to solve… help?

  • 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-20T18:24:22+00:00Added an answer on May 20, 2026 at 6:24 pm

    I’ve added an event handler on ComboBox.Leave this code would add the newly typed in string in the combobox to the underlying list(countries) as well as refresh the combobox binding to it.

    Limitations

    1. You’d have to handle the addition of new element based on the type of datasource you have.
    2. The List.Contains is case sensitive you might want to keep all the strings in one case. And convert the user entered value to that case before deciding to add it to the datasource.

    Here you go, modify the comboBox1_Leave eventhandler according to your datatypes and datasource.

    public partial class Form1 : Form
    {
        private List<string> countries;
        public Form1()
        {
            InitializeComponent();
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
            countries = new List<string>();
            countries.Add("Australia");
            countries.Add("Belgium");
            countries.Add("Canada");
            comboBox1.DataSource = countries;
        }
    
        private void comboBox1_Leave(object sender, EventArgs e)
        {
            ComboBox combo = (sender as ComboBox);
            CurrencyManager cm = (combo.BindingContext[combo.DataSource] as CurrencyManager);
            if (!cm.List.Contains(combo.Text))
            {
                cm.List.Add(combo.Text);
                cm.EndCurrentEdit();
                cm.Refresh();
                cm.Position = cm.Count - 1;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, just like the title says, I need to create an application that gets
Like the title says, I want to parse XML in my iPhone application, but
Just like the title says. I was hoping someone could direct me to documents/resources
Just like the title says, wanted for testing purposes.
Like the title says, If I place an app_offline.htm in the application root, will
Like the title says. I'm sending a simple cUrl cmd from Win7 to CouchDB
I want to write something that acts just like confirm() in javascript, but I
Is there any way to have something that looks just like a file on
Like the title says, I'm trying to find elements of M that exist in
Like the title says, my code basically does this: set proxy, test proxy, do

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.