Removing Duplicates from CListCtrl
-
Hi i have a CListCtrl which contains a list of names, but there are duplicates in them, i need a function to remove them ne1 ne ideas ??? :confused: thanks si
something like this:
bool bIdExists = false; CString strIdListTemp = ""; for(int i = 0; i< m_messageList.GetItemCount(); i++) { CString strIdList = m_messageList.GetItemText(i, 4); if( strIdList == m_yourDuplicateStr) { strIdListTemp = strIdList; bIdExists = true; } } if(bIdExists) { CString temp = ""; temp.Format("Str: %s already exists", strIdListTemp); AfxMessageBox(temp); } else { //ok, do further processing }
-
Hi i have a CListCtrl which contains a list of names, but there are duplicates in them, i need a function to remove them ne1 ne ideas ??? :confused: thanks si
Maybe your design dictates differently, but rather than remove them after the fact, why not be proactive and prohibit them from being added in the first place?