Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Delete selected items (Read 1917 times)
unisnk
Junior Member
**
Offline


D'Oh!

Posts: 59
Joined: Sep 3rd, 2008
Delete selected items
Sep 24th, 2008 at 10:58am
Print Post  
Hi,

I've a chart with only boxes and arrows. I want to have a popup menu that enables me to delete all selected item.

I've made this code (in Delphi 2007) but it doesn't work as intended: some selected items are not deleted.

Code
Select All
procedure TForm_Main.popDeleteSelectionClick(Sender: TObject);
var I: integer;

begin

  for I:=0 to flowchart1.SelectedBoxes.count-1 do
    flowchart1.DeleteItem(flowchart1.SelectedBoxes[I]);

  for I:=0 to flowchart1.SelectedArrows.count-1 do
    flowchart1.DeleteItem(flowchart1.SelectedArrows[I]);

end;
 



Did I something wrong? Or there is some simpler way?

Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Delete selected items
Reply #1 - Sep 24th, 2008 at 12:25pm
Print Post  
Hi,

Modify the cycles so that SelectedBoxes and SelectedArrows are iterated in the reversed order, from index = count - 1 down to 0. That's necessary because calling DeleteItem() also removes the item from the Selected__ collection.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
unisnk
Junior Member
**
Offline


D'Oh!

Posts: 59
Joined: Sep 3rd, 2008
Re: Delete selected items
Reply #2 - Sep 24th, 2008 at 12:37pm
Print Post  
Great! It works now. Grin

Thank you very much, Stoyan! 8)
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint