实现TXT导入ListView

来源:互联网 发布:淘宝supreme正品店 编辑:程序博客网 时间:2024/05/21 11:15

procedure TForm2.FormCreate(Sender: TObject);
var
  {HtmlPath: string;  }
  F:TextFile;
  s,S1,S2:string;
  i:Integer;
begin
 //得到TXT路径
             s:= (ExtractFilePath(Application.ExeName)+'eMail\')+'eMail.txt';
             assignFile(f,s);
             reset(f);
             while not eof(f) do
             begin
                      readln(f,S);
                       i:=Pos('=',S);
                       S1:=Trim(Copy(S,1,I-1));//提取PID
                       S2:=Trim(Copy(S,I+1,length(S)-I)); //提取PWD
                       with Lv1.items.add do
                       begin
                        caption:=IntToStr(lv1.Items.Count);
                        SubItems.Add(S1);
                        if S2='1' then
                        begin
                             //读取并选中项
                             lv1.Items[lv1.Items.Count-1].Checked:=True;
                        end;
                       end;
            end;
             closefile(f);   
end;

原创粉丝点击