Einzelnen Beitrag anzeigen

Benutzerbild von Matze
Matze
(Co-Admin)

Registriert seit: 7. Jul 2003
Ort: Schwabenländle
14.929 Beiträge
 
Turbo Delphi für Win32
 
#14

Re: Editfeld mit Dropdownmenü

  Alt 24. Dez 2009, 15:19
Dann frickel SelStart und SelLength wieder hinein. Beispielsweise so:

Delphi-Quellcode:
procedure TForm1.Autocomplete(Combobox: TComboBox);
var
  EntryNum: Integer;
  EntryValue: string;
  statistic: TiniFile;
  i: Integer;
  InputLen: integer;
begin
  statistic := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'statistic.ini');
  try
    // read number of entries
    EntryNum := statistic.ReadInteger('Playerlist', 'count', 0);
    InputLen := Length(ComboBox.Text);

    Combobox.Items.Clear;
    Combobox.Items.BeginUpdate;

    // add items
    for i := 1 to EntryNum do
    begin
      EntryValue := statistic.ReadString('Playerlist', IntToStr(i), '');

      if ((EntryValue <> '') and (Pos(LowerCase(Combobox.Text), LowerCase(EntryValue)) = 1)) then
      begin
       Combobox.Items.Add(EntryValue);
      end;
    end;

    Combobox.Items.EndUpdate;

    // get text of the first match
    if Combobox.Items.Count > 0 then
    begin
      ComboBox1.ItemIndex := 0;
      ComboBox1.SelStart := InputLen;
      ComboBox1.SelLength := Length(ComboBox.Text) - InputLen;
    end;
  finally
    FreeAndNil(statistic);
  end;
end;
Ggf. sind noch Anpassungen notwendig.
  Mit Zitat antworten Zitat