带CheckBox全选功能
vari:Integer;begin for I := 0 to lstqq.Items.Count - 1 do begin lstqq.Items[i].Checked:=True; end;end;
删除所选:
vari:Integer;begin for i :=lstqq.items.Count - 1 downto 0 do begin if lstqq.Items[i].Checked then lstqq.Items.Delete(i); end;end;
Listview导出数据到文本:
var i, j: integer; s: string; temp,temp1: string;begin temp := ''; for I := 0 to Lstqq.Items.Count - 1 do begin for j := 0 to lstqq.Items[i].SubItems.Count - 1 do begin temp1:=lstqq.Items.Item[i].Caption; temp:=lstqq.Items.Item[i].SubItems.Strings[j]; s:=temp1+','+temp; AppendTxt(s,'log.txt') end; end;end;procedure TFrmMain.AppendTxt(Str, FileName: String);var f:TextFile;begin if not FileExists(FileName) then FileCreate('log.txt'); AssignFile(f, FileName); //把一个外部文件和一个变量关联起来。 Append(f); //追加方式打开一个文件 Writeln(f, Str); //把字符串写入到变量F Closefile(f); //关闭文件end;