Multiple selected items handling

I have a DBPlanner with several hundred planner items. Holding Ctrl allows me to select multiple items which I want to apply special formatting to. The only way to achieve this it seems is the following code:


for x := 0 to DBPlanner1.Items.Count -1 do 
begin
    Item := DBPlanner1.Items[x];
    if Item.Selected then 
    begin
// do the formatting of the selected item here
    end;
end;

The routine is slow probably because of the number of items, however it is not unusual to have up to 1,000 items displayed. I cannot find a collection object of the selected items that I can cycle through, is this correct?

Laurence Bevan


Slowness might depend on the type of actions you perform on the Planner items but not looping through 1000 items. Looping through 1000 items should be fast.
Try to embed the loop in Planner.Items.BeginUpdate/Planner.Items.EndUpdate if you perform actions on the items in the loop that might cause the Planner to need a refresh.