账号密码显示在listview中

加载文件啊加载文件

var
  txt:TextFile; s:string;  str:TStringList;
begin
//   str:=TStringList.Create;
  AssignFile(txt,'c:\456.txt');
      Reset(txt);   //读打开文件,文件指针移到首
  while not Eof(txt) do
  begin
    Readln(txt,s);
    if s <>'' then

    str:=SplitString(s,'----');
    with TestForm.listview1.Items.Add do
        begin
        caption:=str[0];
        subitems.add(str[1]);
//        subitems.add('hh2');
        end;
  end;
  CloseFile(txt);

换一个

var
s,list:TStringList;    i:Integer;
var
  sL,str: TStringList;   Titem:TListItem;
begin
  sL:= TStringList.Create;
  sL.LoadFromFile('c:\456.txt');
//  sL.Delimiter:= '----';
//  sL.DelimitedText:= '业务1 业务2 业务3 业务4 业务5 业务6';
//str:=TStringList.Create;
for i:=0 to sL.Count-1 do begin
 if sl[i]<>'' then
 str:=SplitString(sL[i],'----');
 // Titem:=ListView1.Items.add;
// Titem.Caption:=str[0];
// TestForm.listview1.Items.Add(str[0]);
    with TestForm.listview1.Items.Add do
        begin
        caption:=str[0];
        subitems.add(str[1]);
//        subitems.add('hh2');
        end;
end;
  sL.Free;

splitstring函数,抄的

function SplitString(Source,Deli:string):TStringList;stdcall;  //拆分字符串函数
var
EndOfCurrentString:byte;
StringList:TStringList;
begin
if source<>'' then begin

    StringList:=TStringList.Create;
    while Pos(Deli,Source)>0 do         //当存在拆分符号时
    begin
      EndOfCurrentString:=Pos(Deli,Source);         //取分隔符的位置
      StringList.add(Copy(Source,1,EndOfCurrentString-1));    //添加项目
      Source:=Copy(Source,EndOfCurrentString+length(Deli),length(Source)-EndOfCurrentString);  //减去已添加项和分隔符
    end;
    Result:=StringList;
    StringList.Add(source);   //如果不存在分隔符时,直接作为项目添加
    Result:=StringList;       //设置返回类型
    end;

end;

加载文本文件,显示在listview以后,要取出listview的数据

var
  qqNum,mima:string;
  i:Integer;
begin
for I := 0 to ListView1.Items.Count-1 do begin

  qqNum:=ListView1.Items[i].Caption;
  mima:=ListView1.Items[i].SubItems[0]    ;
  mmo1.Lines.Add(mima)//验证一下
end;
end;

猜你喜欢

转载自www.cnblogs.com/hi-hooge/p/9247304.html