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?
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
List.Containsis 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.