There is no function to move items inside the list. So the move process has to splitted into delete and insert operations.
For multiple items this can be done in two ways: Deleting all selected items first before inserting them at the new position or perform the delete / insert for each item. An example for single items can be found in the article
Manual reordering of items inside a ListView[
^]. The first method requires that all item data are stored in some way (usually in the clipboard when starting the drag operation).
Both methods require adjusting the indices of the source and destination position after each delete and insert operation.
Pseudo code for the second method:
- Iterate through the selected items
- Copy item data
- Delete item
- Decrement insert index if greater than index of deleted item
- Decrement those remaining source indices that are greater than index of deleted item (this will be all when the iteration is performed from smallest to largest index)
- Insert item
- Increment those remaining source indices that are greater or equal than the insert index
- Increment insert index