Jump to content
Squall_FF8

Access to the ListBox of tComboEdit

Recommended Posts

Hey guys,

I'm trying to implement: when the user presses ArrowDown key on tComboEdit, to open the ListBox and focus it (maybe even to select the first item).
However unlike tComboBox, the LstBox is not exposed. 
How I can get a pointer to it?

Share this post


Link to post

To achieve that you can call the DropDown method of the comboedit.

 

procedure TForm4.ComboEdit1KeyUp(Sender: TObject; var Key: Word; var KeyChar:
    WideChar; Shift: TShiftState);
begin
  if key=vkDown then
    ComboEdit1.DropDown;
end;

 

Edited by Lajos Juhász
example

Share this post


Link to post
Just now, Lajos Juhász said:

To achieve that you can call the DropDown method of the comboedit.

That will do only the halve of the job - to show the ListBox,, but it will not focus it (also some other operations if I have a pointer)

Share this post


Link to post

In my case the itemindex was already 0 that made the selection. You can do it:

 

  if key=vkDown then
  begin
    ComboEdit1.ItemIndex:=0;
    ComboEdit1.DropDown;
  end;

 

Share this post


Link to post
8 minutes ago, Lajos Juhász said:

In my case the itemindex was already 0 that made the selection. You can do it:

 


  if key=vkDown then
  begin
    ComboEdit1.ItemIndex:=0;
    ComboEdit1.DropDown;
  end;

 

Thank you for taking time to help me.
I tried the code from your snippet. It works ... but not how I would like:
- the listBox is not focused

- you can't browse the list with the keyboard
- by setting ItemIndex, you change the text (in the Edit part)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×