首先用OpenDialog多选选择多个文本文件到
Listbox1中,问题就是这里,选择一项之后就自然将这一项的内容读取到Listbox2中,怎么解决??
 
感谢大家了。

解决方案 »

  1.   

    读取的容器不一定非要是LISTBOX MEMO也可以。
      

  2.   

     ListBox1.Items.LoadFromFile(filename);
      

  3.   


    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;
      

  4.   

    自然将这一项的内容读取到Listbox2中 里面的内容读取过来,。。大哥们,确实我够麻烦的。
      

  5.   

    StrLst.LoadFromFile(Listbox1.Items);这个是错误的表达。怎么表达这个意思??  读取Listbox1所选择的一项.
      

  6.   

    若是选择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;