BOOL CTDLFindResultsListCtrl::AddHeaderRow(LPCTSTR szText) { if (m_nCurGroupID == -1) EnableGroupView(); return InsertGroupHeader(-1, ++m_nCurGroupID, szText); }
//------------------------------------------------------------------------ //! Create a group for each unique values within a column //! //! @param nCol The index of the column //! @return Succeeded in creating the group //------------------------------------------------------------------------ BOOL CGridListCtrlGroups::GroupByColumn(int nCol) { CWaitCursor waitCursor; SetSortArrow(-1, false); SetRedraw(FALSE); RemoveAllGroups(); EnableGroupView( GetItemCount() > 0 ); if (IsGroupViewEnabled()) { CSimpleMap<CString,CSimpleArray<int> > groups; // Loop through all rows and find possible groups for(int nRow=0; nRow<GetItemCount(); ++nRow) { CString cellText = GetItemText(nRow, nCol); int nGroupId = groups.FindKey(cellText); if (nGroupId==-1) { CSimpleArray<int> rows; groups.Add(cellText, rows); nGroupId = groups.FindKey(cellText); } groups.GetValueAt(nGroupId).Add(nRow); } // Look through all groups and assign rows to group for(int nGroupId = 0; nGroupId < groups.GetSize(); ++nGroupId) { const CSimpleArray<int>& groupRows = groups.GetValueAt(nGroupId); DWORD dwState = LVGS_NORMAL; #ifdef LVGS_COLLAPSIBLE if (IsGroupStateEnabled()) dwState = LVGS_COLLAPSIBLE; #endif VERIFY( InsertGroupHeader(nGroupId, nGroupId, groups.GetKeyAt(nGroupId), dwState) != -1); for(int groupRow = 0; groupRow < groupRows.GetSize(); ++groupRow) { VERIFY( SetRowGroupId(groupRows[groupRow], nGroupId) ); } } SetRedraw(TRUE); Invalidate(FALSE); return TRUE; } SetRedraw(TRUE); Invalidate(FALSE); return FALSE; }