I have a Combobox with 3 item by Default and I want to save items like this:
Item1 //don't save
Item2 //Don't save
Items3 //save
//save all futur items added
Why my code it’s don’t work?
if Combobox1.ItemIndex > 2 then // i used 2 for test and it's no work
Combobox1.Items.SaveToFile('util.conf');
end;
If I remove if Combobox1.ItemIndex > 2 then all items are saved…
How to solve this problem?
Copy the items to a temporary list and then remove whichever you want to remove from that temporary list. Then save it. For example, this code will remove the first two element from the list.
I’m not sure if I fully understand which elements of the list need to be removed. No matter, the basic idea of copying to a different list and saving that, is almost certainly what you need. You will surely be able to work out which elements need to be deleted.