Forum > LCL

Completion for a TEdit

(1/1)

FRex:
I need to create live completion (like you get in code editors) for a TEdit. I'd make it myself, based on content of that TEdit. Right now I use a read only memo that is just below the TEdit but it comes with problems, you can't press down key to go into that list to pick from it, it goes off screen if the list is long, etc.

Is there a convenient way to get some sort of completion list to a TEdit or similar widget that has completion? I'd not want to put a 1 line TSynEdit there, that seems too silly and hacky.

jamie:
TComboBox is basically what you are after.
 
It comes with a TEdit and a drop down  list that does not get covered.

You'll need to work the code in.

taazz:
you can see an example with list boxes (not memo) at https://github.com/taazz/Turbobird/blob/master/trunk/Frames/ufrfonteditor.pas there are a couple of pairs in that frame that do the same thing in short there are 3 events of interest in the tedit you have the onchage event and the onkeydown and on the list box you have the onselectionchange.
You can replace the listbox, if you do not want the visual list/clatter etc, with a stringlist and you are set.

FRex:
TComboBox was very similar to what I wanted but sometimes got in my way. In the end I replaced my TMemo by a TListBox to allow going through it with arrow keys and then handle few keys in OnKeyDown event to fill the original TEdit back. The TListBox is still filled when TEdit changes, just like TMemo was. If someone is really interested there is a link in my forum signature to the project (Botes) I'm doing this all for.

Navigation

[0] Message Index

Go to full version