I end up with all the deliveries in the following array
public static ArrayList myDeliveries = new ArrayList();
It is loaded into the listview. I select an item as follows:
iDeliverySelected = lstDeliveryDetails.SelectedItems[0].Index;
I am struggling to understand how I can select an item and use a delete button to remove it from the text file?
If you need to save a set of objects to disk, then read them back (and do that repeatedly as the objects change), I would say you need to look into serialization and deserialization.
This is essentially what you are doing already manually, but there are ways to automate this and make it easier.
You can use the
XMLSerializerclass to do this, but you will have to mark yourDeliveryobjects with theSerializableAttributeif they are not yet marked as such.Edit: (following comments and update to question)
If, before calling
saveFile(), you remove the selected item from the ArrayList, it will get saved without that item: