怎样做类似IE地址栏的自动完成的效果????急!!!!!!!!!!!

解决方案 »

  1.   

    procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
    var
      i:integer;
      BCanAdd:boolean;
    begin
      if key=#13 then
      begin
        BCanAdd:=true;
        for i:=0  to  ComboBox1.Items.Count-1 do
        begin
          if ComboBox1.Text =ComboBox1.Items[i] then
          begin
            BCanAdd:=false;
            break;
          end;    end;
        if BCanAdd then ComboBox1.Items.Add(ComboBox1.Text)
      end;
        Caption:=ComboBox1.Text;
    end;procedure TForm1.FormDestroy(Sender: TObject);
    begin
      ComboBox1.Items.SaveToFile(GetCurrentDir+'\1.txt');
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      if FileExists(GetCurrentDir+'\1.txt') then
        ComboBox1.Items.LoadFromFile(GetCurrentDir+'\1.txt');
      ComboBox1.AutoDropDown:=true;
    end;
      

  2.   

    其实delphi的下来列表中就有自动完成的功能,不信你试试