Combo Boxes final text value has to be on the list.

Hello all,

I cannot seem to find the answer that I am looking for so... I have a combo box with the DropDownStyle set to DropDown. I want users to be able to type and get the suggested options, but I do not want user's to type and leave a value that is not on the list. I have the SuggestAppend set for AutoComplete, but users can set the combo boxes text value to something that is not on the list.  Originally, I had the DropDownStyle set to DropDownList but the color change bothered me and all the solutions I found did not seem to let me change the BackColor. Can some please help me with getting the BackColor changed to "white" for a DropDownList  combo box or help me programically change the behavior of the combo box to not allow the value to equal something that is not on the list?

**Change the FlatStyle property to Popup is not an option.

Thank you for your assistance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shane KahkolaFreelancerCommented:
Since I'm not sure which version of .NET you are using. Here is a rudimentary solution to your question. I would create a Leave() event on your ComboBox that looks something like this:
        private void comboBox1_Leave(object sender, EventArgs e)
            message.Text = string.Empty;

            string t = comboBox1.Text;
            if (!comboBox1.Items.Contains(t))
                comboBox1.Text = string.Empty;
                //Here you would update some text element on the form informing the user they must only provide a value in the list.
                message.Text = "You must choose from the list.";


Open in new window

If this isn't what you were asking, can you maybe provide a bit of sanitized code?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShannonCallahanAuthor Commented:
Thank you for the assistance!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.