Search code examples
delphidelphi-xe2delphi-7delphi-2010

Manually scrolling through a TComboBox


I have not been able to figure out why I am unable to manually scroll through a TComboBox component when I programatically cause the drop down pick list to appear. Here is the code I am using:

SendMessage(ComboBox1.handle, CB_SHOWDROPDOWN, Integer(True), 0);

This causes the drop down pick list to appear. However, if I try to use my keyboard and use the up and down arrow keys, the drop down pick list immediately closes. How do I keep the list from auto-closing when using the keyboard up/down navigation keys?


Solution

  • Activate the ComboBox. And you'd better use the DroppedDown property, which also invalidates the combobox to reflect the change.

    ActiveControl := ComboBox1;
    ComboBox1.DroppedDown := True;