procedure TForm1.Button4Click(Sender: TObject); var i : integer; begin for i := 0 to combobox1.Items.Count - 1 do begin if listbox1.Items.IndexOf(combobox1.Items.Strings[i]) = -1 then //关键是这句 listbox1.Items.Add(combobox1.Items.Strings[i]); end; end;
怎么选一个,全部都加进去了?procedure TForm1.ComboBox1Change(Sender: TObject); var i : integer; begin for i := 0 to (combobox1.Items.Count - 1) do begin if listbox1.Items.IndexOf(combobox1.Items.Strings[i]) = -1 then //关键是这句 listbox1.Items.Add(combobox1.Items.Strings[i]); end; end;end. 怎么选一个,全部都加进去了?
procedure TForm1.ComboBox1Select(Sender: TObject); var I:integer; Exist:Boolean; begin Exist:=False; for I:=1 to ListBox1.Items.Count do begin if ListBox1.Items[I-1] = ComboBox1.Text then Exist:=True; end; if not Exist then begin ListBox1.Items.Add(Combobox1.Text); end; end;
var
i : integer;
begin
for i := 0 to combobox1.Items.Count - 1 do
begin
if listbox1.Items.IndexOf(combobox1.Items.Strings[i]) = -1 then //关键是这句
listbox1.Items.Add(combobox1.Items.Strings[i]);
end;
end;
var
i : integer;
begin
for i := 0 to (combobox1.Items.Count - 1) do
begin
if listbox1.Items.IndexOf(combobox1.Items.Strings[i]) = -1 then //关键是这句
listbox1.Items.Add(combobox1.Items.Strings[i]);
end;
end;end.
怎么选一个,全部都加进去了?
var I:integer;
Exist:Boolean;
begin
Exist:=False;
for I:=1 to ListBox1.Items.Count do
begin
if ListBox1.Items[I-1] = ComboBox1.Text then Exist:=True;
end;
if not Exist then
begin
ListBox1.Items.Add(Combobox1.Text);
end;
end;
我只想加入的是combobox1中有的内容