I have two problems with deleting multiple (selected) items in a listview.
The problems are caused by the fact that apparantly it is not possible to manipulate the j integer (decrease it by 1 after finding a selected record) and that apparantly Items.Count in the for statement is not updated after deleting an item which results in errors at the end of the list.
The last problema I solved with:
After deleting an item, all items below move up. How can I keep i on the same value after deleting a record to check the state of the next item that now has the index of the deleted item?
Code:
with ListView1 do
for j := 0 to Items.Count - 1 do
if Items[j].Selected then
ListView1.Items[j].Delete;
The problems are caused by the fact that apparantly it is not possible to manipulate the j integer (decrease it by 1 after finding a selected record) and that apparantly Items.Count in the for statement is not updated after deleting an item which results in errors at the end of the list.
The last problema I solved with:
Code:
with ListView1 do
for j := 0 to Items.Count - 1 do
if j < Items.Count then
if Items[j].Selected then
lvHeaders.Items[j].Delete;
After deleting an item, all items below move up. How can I keep i on the same value after deleting a record to check the state of the next item that now has the index of the deleted item?