AutoComplete and (Lookup)Combo possible?
Posted 14 February 2011 - 12:44 PM
As a result the user can't select the desired value by typing the first few characters.
In list we might have:
- Booz 30Cl
- Booz 50Cl
- Cheerz 30Cl
- Cheerz 50Cl
Typing 'Cheerz 5' should select 'Cheerz 50Cl', but instead it only selects the first entry with that letter ( 'Cheerz 30Cl' )
I tried using the AutoComplete-control according to the example provided on this website, but it doesn't appear to work at all.
It's also a lot of extra code (for filling the autocomplete list) that probably can be avoided as well.
Posted 15 February 2011 - 02:03 PM
However I noticed that the user always has to press 'backspace' in order to activate this feature.
Posted 16 February 2011 - 03:58 PM
I did however manage to get a partial fix that gets rid of the backspace requirement.
As I already was using the keydown-event to start the editor whenever the user pressed the spacebar I used this code :
procedure TfrShiftProducts.grdShiftProductsKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
// if 'spacebar' is pressed ...
if(Key = VK_SPACE) then
// start the editor for the selected cell :
// this routine is needed to start autocomplete
// set Key to 0 as we don't want it anymore
Key := 0
iHandle : HWND;
iLast : integer;
// get the handle for the active editor and the length of the text
if grdShiftProducts.Columns[grdShiftProducts.SelectedColumn].InplaceEdit = Nil then
iHandle := grdShiftProducts.Columns[grdShiftProducts.SelectedColumn].Editor.Handle;
iLast := Length(grdShiftProducts.Columns[grdShiftProducts.SelectedColumn].Editor.Text)
iHandle := grdShiftProducts.Columns[grdShiftProducts.SelectedColumn].InplaceEdit.Handle;
iLast := Length(grdShiftProducts.Columns[grdShiftProducts.SelectedColumn].InplaceEdit.Tex
// this appears to 'fix' it :
SendMessage(iHandle, EM_SETSEL, 0, MakeLParam(iLast - 1, iLast - 1));
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users