Click to See Complete Forum and Search --> : deleting list items


April 15th, 1999, 10:19 PM
How do you delete a selected list item?

Eddie Owen
April 15th, 1999, 11:46 PM
If we're talking about a CListCtrl, then the following will do it:

POSITION pos;
int iCount;

pos = m_ListCtrl.GetFirstSelectedItemPosition();

while (pos)
{
iCount = m_ListCtrl.GetNextSelectedItem(pos);
m_ListCtrl.DeleteItem(iCount);
}

Just remember that if you are doing a multiple delete, then you should delete in reverse order since the index numbers change after every delete.

Eddie