You have to exchange the items. Get the item contents by index (index 0 and 3 in your example) into variables and set them using the other variable.
How to do this depends on your list style (report or not) and the amount of information stored per item (text, image, check box, user data).
For a report list you have to iterate also over the columns and exchange the text for each column.
See
CListCtrl Class[
^] for the functions to be used. Candidates are
GetItemText
and
SetItemText
for the text (text of columns with report mode),
GetItemData
and
SetItemData
for user data, or
GetItem
and
SetItem
for multiple settings (image, state, text, format).
Example (assuming the code is part of a
CListView
derived class):
int item1 = 0;
int item2 = GetListCtrl().GetNextItem(-1, LVNI_SELECTED);
int columns = GetListCtrl().GetHeaderCtrl().GetItemCount();
for (int i = 0; i < columns; i++)
{
CString str1 = GetListCtrl().GetItemText(item1, i);
CString str2 = GetListCtrl().GetItemText(item2, i);
GetListCtrl().SetItemText(item1, i, str2);
GetListCtrl().SetItemText(item2, i, str1);
}