去掉Dblookupeh控件的自己填充功能

来源:互联网 发布:迅雷linux版 编辑:程序博客网 时间:2024/06/10 07:48

这个自动填充功能当数据出现

aa
aaa
aaaa

时就会出现aaa 最后一个a删不掉的情况。
解决方法就去掉这个自动填充功能。
在特定情况可以加快这个控件的速度

打开Dblookupeh.pas 文件一般在 delphi/bin/ 目录下
找到
function TCustomDBLookupComboboxEh.LocateStr(Str: String; PartialKey: Boolean): Boolean;
var
  Options: TLocateOptions;
  CurOnChangeEvent: TNotifyEvent;
begin
  Result := False;
  if not FListActive or not CanModify(True) then Exit;
  if PartialKey then
    Options := [loCaseInsensitive, loPartialKey]
  else
    Options := [loCaseInsensitive];
  try
    Result := FListLink.DataSet.Locate(FListField.FieldName, Str, Options);
    if Result then
    begin
      FTextBeenChanged := False;
      CurOnChangeEvent := OnChange;
      OnChange := HookOnChangeEvent;
      SetKeyValue(FListLink.DataSet.FieldValues[FKeyFieldName]);
      SetEditText(FListField.DisplayText);
      SelStart := Length(Text);
      SelLength := Length(Str) - SelStart;
      OnChange := CurOnChangeEvent;
      if FTextBeenChanged and Assigned(OnChange) then
        OnChange(Self);
    end else if Style = csDropDownEh then
      SetKeyValue(Null);
  except
    { If you attempt to search for a String larger than what the field
      can hold, and exception will be raised.  Just trap it and
      reset the SearchText back to the old value. }
    if Style = csDropDownListEh then
    begin
      SetEditText(Text);
      SelStart := Length(Text);
      SelLength := Length(Text) - SelStart;
    end else
      SetKeyValue(Null);
  end;
end;

-------------
把if Result then 改为 if False then

再打开原程序,,重新编绎