CS15|f:\langame\|CS15|\cstrike.exe|2.1|20080924135213|20080924135213|1661|
CS16|f:\langame\|CS16|\cstrike.exe|2.1|20080924135948|20080924135948|1705|
FIFA2008|f:\langame\|FIFA2008|\FIFA08_cn.exe|2|20080924140504|20080924140504|2539|
IS语音|f:\聊天软件\|IS语音|\iSpeak.exe|2.3|20080924140510|20080924140510|6|
MSN|f:\聊天软件\|MSN|\msnmsgr.exe|2.3|20080924140517|20080924140517|45|
我想将上面格式的文件读入到listview中,需要以|为分割符,不知道怎么写,求教各位大校了
CS16|f:\langame\|CS16|\cstrike.exe|2.1|20080924135948|20080924135948|1705|
FIFA2008|f:\langame\|FIFA2008|\FIFA08_cn.exe|2|20080924140504|20080924140504|2539|
IS语音|f:\聊天软件\|IS语音|\iSpeak.exe|2.3|20080924140510|20080924140510|6|
MSN|f:\聊天软件\|MSN|\msnmsgr.exe|2.3|20080924140517|20080924140517|45|
我想将上面格式的文件读入到listview中,需要以|为分割符,不知道怎么写,求教各位大校了
var List:TStringList;
i,j,ColCount:Integer;
S:string;
NewCol:TListColumn;
NewItem:TListItem;
begin
ListView1.ViewStyle:=vsReport;
List:=TStringList.Create;
try
List.LoadFromFile('C:\Documents and Settings\Administrator\桌面\tmp.txt');
i:=0;
ColCount:=0;
while i<=List.Count-1 do
with ListView1 do
begin
S:=List.Strings[i];
NewItem:=Items.Add;
while Pos('|',S)>0 do
begin
if i=0 then
begin
Inc(ColCount);
NewCol:=Columns.Add;
NewCol.Caption:='第'+IntToStr(ColCount)+'列';
end;
if NewItem.Caption='' then
NewItem.Caption:=Copy(S,1,Pos('|',S)-1)
else
NewItem.SubItems.Add(Copy(S,1,Pos('|',S)-1));
Delete(S,1,Pos('|',S));
end;
Inc(i);
end;
finally
List.Free;
end;
end;