unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    ComboBox1: TComboBox;
    Button1: TButton;
    Edit1: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    function gettext(index:integer):string;
  end;var
  Form1: TForm1;
  
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
   combobox1.Text:='';
   combobox1.Items.Add('中国');
   combobox1.Items.Add('美国');
   combobox1.Items.Add('法国');
   combobox1.Items.Add('英国');
   button1.Caption:='添加';
end;procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
   for i:=0 to combobox1.Items.Count do
     begin
         if edit1.Text=gettext(i) then
         begin
           exit;
         end;
     end;
     combobox1.Items.Add(edit1.Text);
end;function TForm1.gettext(index: integer): string;
begin
  combobox1.ItemIndex:=index;
  result:=combobox1.Text;
end;end.
注:
combobox1 已有选项:
中国
美国
法国
英国向其添加"中国",不响应
结果仍然是:
中国
美国
法国
英国向其添加"德国",响应
结果是:
中国
美国
法国
英国
德国我的做法可以实现功能
但是当I很大时,循环次数就很大,请大虾指点更合理的做法,谢了.