How to sort the rows of CListCtrl
-
How to sort the rows of CListCtrl depanding upon Particular column. Or Please tell me how to use CListCtrl::SortItems function for sorting.
-
How to sort the rows of CListCtrl depanding upon Particular column. Or Please tell me how to use CListCtrl::SortItems function for sorting.
Hi Anil, you need to create a callback function that will be called each time the two items in the list control need to be compared. int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); BOOL SortItems( PFNLVCOMPARE pfnCompare, DWORD_PTR dwData ); Pass a pointer to the sort items function for the callback function. Vision is Always important and so is your ATTITUDE. Wishes. Anshuman Dandekar
-
Hi Anil, you need to create a callback function that will be called each time the two items in the list control need to be compared. int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); BOOL SortItems( PFNLVCOMPARE pfnCompare, DWORD_PTR dwData ); Pass a pointer to the sort items function for the callback function. Vision is Always important and so is your ATTITUDE. Wishes. Anshuman Dandekar
_AnShUmAn_ wrote:
BOOL SortItems( PFNLVCOMPARE pfnCompare, DWORD_PTR dwData );
The above function internally sends the LVM_SORTITEMS message.. I found the LVM_SORTITEMSEX message is more easy to use than LVM_SORTITEMS . U can use
ListView_SortItemsEx Macro
to send LVM_SORTITEMSEX message nave -
How to sort the rows of CListCtrl depanding upon Particular column. Or Please tell me how to use CListCtrl::SortItems function for sorting.
anilksingh wrote:
How to sort the rows of CListCtrl depanding upon Particular column.
Provide a
HDN_ITEMCLICK
handler. In that handler function, the column that was clicked is:HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
m_nSortColumn = phdn->iItem;Now call
SortItems()
.anilksingh wrote:
Or Please tell me how to use CListCtrl::SortItems function for sorting.
Be sure to call
SetItemData()
when adding items to the list control.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb