I copied this topic form
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-autocomplete-a-lookup-field-in-Dbgrid-td4057046.htmlI have a a dataset with a lookup field.
I edit it with a dbgrid.
The grid correctly uses a picklist for that field, but I couldn't find
an easy way to autocomplete it (i.e. allow the user to type the first
few characters of the value to select an entry).
The problem seems to be that the picklist field uses a
TPickListCellEditor which derives from a TCustomComboBox that doesn't
implement such functionality (it does but only to set the text in case
it's a csDropDownList, it doesn't set the selected item).
I see that a TDBLookupCombobox supposedly implements autocomplete (I saw
some forum post when they say it's problematic, don't know if it has
been solved now), but I cannot use it since I'm setting two fields, not one.
Any idea?
I have exactly the same problem.
I did a following change in Grids.pas, line 9229 and below
FPickListEditor.Items.Assign(C.PickList);
FPickListEditor.DropDownCount := C.DropDownRows;
FPickListEditor.Style := csDropDown;
FPickListEditor.ItemWidth := FPickListEditor.Width*3;
FPickListEditor.AutoComplete := true;
FPickListEditor.AutoDropDown := True;
FPickListEditor.AutoCompleteText := [cbactEnabled, cbactEndOfLineComplete, cbactSearchAscending];
FPickListEditor.ReadOnly := False;
Now Combo drops down automatically, but still not autocomplete.
It will not change Text propery of the TPickListCellEditor control.
But if I use normal pick list instead of LookupField, Autocomplete works perfect with changes above.
Any ideas?
Trunc, Windows 64 bit.
[Edited to add code tags - see
How to use the Forum.]