Changes in TJvDBGrid TJvDBGrid = class(TJvExDBGrid) private .. protected .. procedure InternalKeyPress(var Key: Char; AChar: TFieldChars); virtual; function SelectCell(ACol, ARow: Integer): overload; public .. end; procedure TJvDBGrid.KeyPress(var Key: Char); const cChar = ['A'..'Z', 'a'..'z', ' ', '-', '+', '0'..'9', '.', ',', 'é', 'è', 'ê', 'ë', 'ô', 'û', 'ù', 'â', 'à', 'î', 'ï', 'ç', #8]; begin // Remark: InplaceEditor is protected in TCustomGrid, published in TJvDBGrid // Goal: Allow to go directly into the InplaceEditor when one types the first // characters of a word found in the list. if not ReadOnly then if (Key = #13) and FPostOnEnter then DataSource.DataSet.CheckBrowseMode else if not(Columns[SelectedIndex].ReadOnly) then InternalKeyPress(Key,cChar); if EditorMode then inherited OnKeyPress := FOnKeyPress; try inherited KeyPress(Key); finally inherited OnKeyPress := nil; end; end; procedure TJvDBGrid.InternalKeyPress(var Key: Char; AChar: TFieldChars); var lWord: string; lMasterField: TField; I, deb: Integer; begin with Columns[SelectedIndex].Field do if FieldKind = fkLookup then begin if (Key in AChar) then begin if Pos(AnsiUpperCase(FWord), AnsiUpperCase(InplaceEditor.EditText)) <> 1 then FWord := ''; if Key = #8 then if (FWord = '') or (Length(FWord) = 1) then begin lWord := ''; FWord := ''; end else lWord := Copy(FWord, 1, Length(FWord) - 1) else lWord := FWord + Key; LookupDataSet.DisableControls; try try if LookupDataSet.Locate(LookupResultField, lWord, [loCaseInsensitive, loPartialKey]) then begin DataSet.Edit; lMasterField := DataSet.FieldByName(KeyFields); if lMasterField.CanModify then begin lMasterField.Value := LookupDataSet.FieldValues[LookupKeyFields]; FWord := lWord; InplaceEditor.SelStart := Length(FWord); InplaceEditor.SelLength := Length(InplaceEditor.EditText) - Length(FWord); end; end; except { If you attempt to search for a string larger than what the field can hold, and exception will be raised. Just trap it } end; finally LookupDataSet.EnableControls; end; end; end else if FieldKind = fkData then begin if DataType = ftFloat then if Key in ['.', ','] then Key := DecimalSeparator; if (Key in AChar) and (Columns[SelectedIndex].PickList.Count <> 0) then begin if Pos(AnsiUpperCase(FWord), AnsiUpperCase(InplaceEditor.EditText)) <> 1 then FWord := ''; if Key = #8 then if (FWord = '') or (Length(FWord) = 1) then begin lWord := ''; FWord := ''; end else lWord := Copy(FWord, 1, Length(FWord) - 1) else lWord := FWord + Key; Key := #0; // De toute façon le caractère est supprimé with Columns[SelectedIndex].PickList do for I := 0 to Count - 1 do begin deb := Length(lWord); if AnsiUpperCase(lWord) = AnsiUpperCase(Copy(Strings[I], 1, deb)) then begin DataSet.Edit; InplaceEditor.EditText := Strings[I]; Columns[SelectedIndex].Field.Text := Strings[I]; InplaceEditor.SelStart := deb; InplaceEditor.SelLength := Length(Text) - deb; FWord := lWord; Break; end; end; end; end; end; function TJvDBGrid.SelectCell(ACol, ARow: Integer): Boolean; begin FWord:=''; Result:=inherited SelectCell(ACol, ARow); end;