How to add items to a TComboBox upon an [ENTER] key press (Views: 100)
I would like my user to be able to enter items into a combobox and add each item upon pressing the enter key. Is there a simple way to do this. I started using csdropdown style. Then I tried using the keydown event with key 13, so that when the user presses enter, the user's entry is added to combobox.items, but so far its not working. I'll keep hacking away at it, but I thought perhaps there is an existing solution to this problem, either starting from a different control, or using a different method in TComboBox.
This works for me on a csDropDown combobox (D5.01):
procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
if key = #13 then
if combobox1.text <> emptystr then
key := #0;
<< Back to main page