
August 27th, 2004, 01:08 AM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 7
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Deleting selected item in TListView
For some reason, when i try to delete a selected item in the TListView, i get EAccessViolation Error. But the code still deletes the selected item. Here is what i have.
Code:
procedure TForm1.Button6Click(Sender: TObject);
var
i: integer;
begin
try
with Listview1 do
for i := 0 to Items.Count - 1 do
if Items[i].Selected then
Items.Delete(Items.IndexOf(FindCaption(0, Items[i].Caption, False, True, False)));
except on EAccessViolation do
// silent
end;
end;
I had to catch the exception to make it stop showing that error message. But why is it causing it? The code seems to be fine and logical. Any help would be appreciated. Thank you!
|