ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TImageEnMView Delete Checked Thumbnails
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

w2m

USA
1990 Posts

Posted - Aug 24 2014 :  09:55:04  Show Profile  Reply
if you take the ...multi\checkboxes demo and add a button to the form then add this code to the buttons click event, the checked thumbnails are not deleted. Why? After checking 3 thumbnails, one thumbnail remains checked and is not deleted.

// Delete checked images
procedure TMainForm.DeleteChecked1Click(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to ImageEnMView1.ImageCount-1 do
    if ImageEnMView1.Checked[I] then
    begin
      ImageEnMView1.DeleteImage(I);
    end;
  ImageEnMView1.Update;
end;


Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development

xequte

38616 Posts

Posted - Aug 24 2014 :  22:19:15  Show Profile  Reply
Hi Bill

If you delete the first item in the list, then the second item becomes the first one, the third item becomes the second one, etc. So if you have deleted some earlier items in the list by the time you get to the end that referenced item would no longer exist.

Either work backwards (for I := ImageEnMView1.ImageCount-1 downto 0 do) or only increment the iteration variable if you do not delete an item.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: