procedure TForm1.ListBox1Click(Sender: TObject); var i:integer; begin for i:=0 to ListBox1.Items.Count-1 do begin if Listbox1.Selected[i] then listbox2.Items.Add(Listbox1.Items[i]); end; end;
若是选择Listbox1某一项添加到ListBox2中? 像5楼的就行了--若是从外部文本文件读入到ListBox1中,下面可参考: --ListBox3.Visible:=False; --读入内容到ListBox3后,添加ListBox3的记录到ListBox1 --这样不会每次都清空ListBox1,而是将新文件内容添加到ListBox1未尾 --其它文件类型就另当别论了 if OpenDialog1.Execute then begin ListBox3.Items.LoadFromFile(OpenDialog1.FileName); ListBox1.Items.AddStrings(ListBox3.Items); end;
procedure TForm1.ListBox1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to ListBox1.Items.Count-1 do
begin
if Listbox1.Selected[i] then
listbox2.Items.Add(Listbox1.Items[i]);
end;
end;
像5楼的就行了--若是从外部文本文件读入到ListBox1中,下面可参考:
--ListBox3.Visible:=False;
--读入内容到ListBox3后,添加ListBox3的记录到ListBox1
--这样不会每次都清空ListBox1,而是将新文件内容添加到ListBox1未尾
--其它文件类型就另当别论了
if OpenDialog1.Execute then
begin
ListBox3.Items.LoadFromFile(OpenDialog1.FileName);
ListBox1.Items.AddStrings(ListBox3.Items);
end;