默认的TComboBox上下键是可以选择值的,但下拉框默认是隐藏的,只需要上下键触发keydown事件把下拉框显示出来就OK
代码:
procedure TForm1.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key in [VK_DOWN, VK_UP] then
begin
if not ComboBox1.DroppedDown then
begin
ComboBox1.DroppedDown := true;
SendMessage(ComboBox1.Handle, WM_SETCURSOR, 0, 0);
end;
end;
end;