怎么填写listview的相应的列?
如何填写listview的相应的列?急
读标准的文件后,怎么插入到制定的列啊?
如:文件格式为:
1234567890 abcde 123.00
我想插入到listview第一列,第二列,第四列中,怎么写啊?
我的源码
listview2.Items.Clear;
s:=TStringList.Create;
s.LoadFromFile(filename); //读文件
for i:=0 to s.Count -1 do
begin
strs:=tstringlist.Create;
strs.Delimiter := ' ';
strs.DelimitedText := s.Strings[i];
listitem:=listview2.Items.add;
listitem.Caption:=strs[0];
/*****这一段怎么填写?
listitem.SubItems.Add(strs[1]);
listitem.SubItems.Add(strs[2]);
****/
strs.Clear;
end;
好像问题很多,请大家指教!
------解决方案--------------------
第一列是Caption
/*****这一段怎么填写?
listitem.SubItems.Add(strs[1]); //第二列
listitem.SubItems.Add( ' ');//第三列
listitem.SubItems.Add(strs[2]);//第四列
****/
对于已经存在的可以
listitem.SubItems.Strings[0] := strs[1]; //第二列
listitem.SubItems.Strings[1] := ' ';//第三列
listitem.SubItems.Strings[2] := strs[2];//第四列
可以用listitem.SubItems.Count来判断列是否已经存在
------解决方案--------------------
while not ADOQuery1.Eof do
begin
with ListView1.Items.Add do
begin
Caption:=ADOQuery1.fieldbyname( 'pjbianhao ').AsString;
SubItems.Add(ADOQuery1.fieldbyname( 'pjename ').AsString);
SubItems.Add(ADOQuery1.fieldbyname( 'pjpinyin ').AsString);
SubItems.Add(ADOQuery1.fieldbyname( 'pjchexing ').AsString);
SubItems.Add(ADOQuery1.fieldbyname( 'pjjiage ').AsString);
SubItems.Add(ADOQuery1.fieldbyname( 'pjmemo ').AsString);
end;
ADOQuery1.Next;
end;
ADOQuery1.close;
读标准的文件后,怎么插入到制定的列啊?
如:文件格式为:
1234567890 abcde 123.00
我想插入到listview第一列,第二列,第四列中,怎么写啊?
我的源码
listview2.Items.Clear;
s:=TStringList.Create;
s.LoadFromFile(filename); //读文件
for i:=0 to s.Count -1 do
begin
strs:=tstringlist.Create;
strs.Delimiter := ' ';
strs.DelimitedText := s.Strings[i];
listitem:=listview2.Items.add;
listitem.Caption:=strs[0];
/*****这一段怎么填写?
listitem.SubItems.Add(strs[1]);
listitem.SubItems.Add(strs[2]);
****/
strs.Clear;
end;
好像问题很多,请大家指教!
------解决方案--------------------
第一列是Caption
/*****这一段怎么填写?
listitem.SubItems.Add(strs[1]); //第二列
listitem.SubItems.Add( ' ');//第三列
listitem.SubItems.Add(strs[2]);//第四列
****/
对于已经存在的可以
listitem.SubItems.Strings[0] := strs[1]; //第二列
listitem.SubItems.Strings[1] := ' ';//第三列
listitem.SubItems.Strings[2] := strs[2];//第四列
可以用listitem.SubItems.Count来判断列是否已经存在
------解决方案--------------------
while not ADOQuery1.Eof do
begin
with ListView1.Items.Add do
begin
Caption:=ADOQuery1.fieldbyname( 'pjbianhao ').AsString;
SubItems.Add(ADOQuery1.fieldbyname( 'pjename ').AsString);
SubItems.Add(ADOQuery1.fieldbyname( 'pjpinyin ').AsString);
SubItems.Add(ADOQuery1.fieldbyname( 'pjchexing ').AsString);
SubItems.Add(ADOQuery1.fieldbyname( 'pjjiage ').AsString);
SubItems.Add(ADOQuery1.fieldbyname( 'pjmemo ').AsString);
end;
ADOQuery1.Next;
end;
ADOQuery1.close;