Forum > Databases

Autocomplete a lookup field in Dbgrid

(1/1)

zgabrovski:
I copied this topic form http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-autocomplete-a-lookup-field-in-Dbgrid-td4057046.html


I 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


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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.]

Navigation

[0] Message Index

Go to full version