我想创建一个循环,以便从listview中删除所选项目。
procedure TFContact.BtnDeleteClick(Sender: TObject);
var
SecItem, BUFPath : string;
i : Integer;
begin
if ListViewTab5.Selected <> nil then
for i := 0 to ListViewTab5.Items.Count - 1 do
begin
SecItem:= TListViewItem(ListViewTab5.Selected).Text;
BUFPath:= '/storage/emulated/0/Backup/'+SecItem;
TFile.Delete(BUFPath);
end
else
ShowMessage('File Deleted Succesfully');
end;
答案 0 :(得分:1)
试试这个:
procedure TFContact.BtnDeleteClick(Sender: TObject);
const
Path = '/storage/emulated/0/Backup/';
var
Item: TListViewItem;
begin
for Item in ListView.Items do
if Item.Checked then
TFile.Delete(TPath.Combine(Path, Item.Text));
end;