How to enter a new value in a combobox at runtime?

  • Thread starter Thread starter Guest
  • Start date Start date
I assume that you want the user to be able to type a value into the combobox
at runtime, instead of merely picking an item from the list. To do this, set
the combobox's DropDownStyle to DropDown instead of DropDownList.

Tom Dacon
Dacon Software Consulting
 
Hi Hans,

Third solution. If you want to enter a non existant value in a combobox, and have it added to the list.

Capture the KeyPress event and test for (char)13, which is the enter key, and the Leave event in case you TAB out of the control. Browse through the item list to see if the item already exists, and if not, add it.
 
Back
Top