It is not possible to do this without deleting. You have to create a copy of the row at the new loaction and delete the initial row.
Searching the web for "clistctrl move item up down" gives you examples:
Copying/Moving Rows in CListCtrl[
^]
c++ - Move an item up or down in a list box - Stack Overflow[
^]
[EDIT]
To move items one step it would be possible to exchange them:
- Get item at selected index and store data in variable
- Get item at new position (index +/- 1) and store data in variable
- Set item at selected position with data from new position
- Set item at new position with data from selected position
- Change selection to new position
Untested example:
if (1 != GetSelectedCount())
return;
int sel = GetNextItem(-1, LVNI_SELECTED);
int next = bUp ? sel - 1 : sel + 1;
if (next < 0 || next >= GetItemCount())
return;
CString strSel, strNext;
for (int i = 0; i < GetHeaderCtrl()->GetItemCount(); i++)
{
strSel = GetItemText(sel, i);
strNext = GetItemText(next, i);
SetItemText(sel, i, strNext);
SetItemText(next, i, strSel);
}
SetItemState(sel, ~LVNI_SELECTED, LVIS_SELECTED);
SetItemState(next, LVNI_SELECTED, LVIS_SELECTED);
SetSelectionMark(next);
[/EDIT]