Is there a way to drop down a TJvComboEdit's AutoComplete list when the button is pressed?

做~自己de王妃 提交于 2019-12-13 02:12:32

问题


I have got a form with a TJvComboEdit control (from Jedi Visual Components library, jvcl) on it. This control has got an AutoCompleteList and if I set AutoCompleteOptions to acoUpDownKeyDropsList I can at runtime show this list by pressing the up or down key.

So far, that's fine, but in addition to that I want the control's button to also show that list (like a TComboBox button does) but I can not find any way to do that. The showing of the list seems to be done by some internal IAutoComplete Windows interface which does not expose an api for showing the list.

Am I missing something? Or is there any other control I could use instead? (apart from the obvious TComboBox)?


回答1:


The TJvComboEdit uses the IAutoComplete and IAutoComplete2 interfaces for autocomplete features and there is no way to invoke the drop down list for them manually.

You can use the following hack which sets the focus to the TJvComboEdit and simulate the key.

procedure TForm1.Button1Click(Sender: TObject);
begin
  if JvComboEdit1.CanFocus then
  begin
    JvComboEdit1.SetFocus;
    keybd_event(VK_DOWN, 0, 0, 0);
    keybd_event(VK_DOWN, 0, KEYEVENTF_KEYUP, 0);
  end;
end;


来源:https://stackoverflow.com/questions/9077396/is-there-a-way-to-drop-down-a-tjvcomboedits-autocomplete-list-when-the-button-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!