Print Page | Close Window

CXTPListBase::SortList Method

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=23047
Printed Date: 21 November 2024 at 3:45pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPListBase::SortList Method
Posted By: angelsoriasanagustin
Subject: CXTPListBase::SortList Method
Date Posted: 14 June 2016 at 12:49pm
Hi.

I have a CXTPListCtrl with dates in a column. To sort this data correctly I need to do a custom sort routine. In the documentation I have found CXTPListBase::SortList Method, but there is no explanation about it.

Can anyone give me an example about using it ?

Thanks.



Replies:
Posted By: Alex H.
Date Posted: 15 June 2016 at 2:15am
Hi!

Can you sort the items before adding them to the list?

:-)


Posted By: angelsoriasanagustin
Date Posted: 15 June 2016 at 4:41am
Thanks, but I can't sort before because I have multiple columns, and the user can select what to sort.

I'm testing CXTPListCtrl::SortList()... It's called when the user clicks in a column... Ok.
I'm triying to sort columns using MoveRow() in the function, but doen't work. The rows are sorted by default no matter what I write on the function.

Please do a better documentation... 
Form Help:
Override this member function in your derived class to perform custom sort routines.

How ????


Posted By: olebed
Date Posted: 19 June 2016 at 4:00am
Hello,

You can explore method CXTPShellListBase::SortList

CXTPShellListBase is derived from CXTPListBase.

Regards,
 Oleksandr Lebed


Posted By: angelsoriasanagustin
Date Posted: 21 June 2016 at 6:16am
Ok, but the help says same:

Override this member function in your derived class to perform custom sort routines.

How ?????

Thanks.


Posted By: angelsoriasanagustin
Date Posted: 07 July 2016 at 3:02am
Please... any idea ?
Thanks


Posted By: cluster
Date Posted: 07 July 2016 at 5:14am
Hi,
Codejock used the sort mechanism from CListCtrl:
...
    m_pListCtrl->SortItems(
        ListViewCompareProc, (nCol + 1)*(bAscending? 1: -1));
...
so you need a own Callback function like:
static int CALLBACK MyCompareProc(LPARAM lparam1, LPARAM lparam2, LPARAM lparamSort);

here is an example:
http://www.codeproject.com/Articles/1901/Example-of-CListCtrl-SortItems-in-MSDN

I hope this helps!


Posted By: angelsoriasanagustin
Date Posted: 07 July 2016 at 1:13pm
Thanks for the help...

I was using other example: http://www.codeproject.com/Articles/27774/CListCtrl-and-sorting-rows

The example works with a standar control, but if I use a derived class of CXTPListCtrl no matter what I do, always is sorted by default.

My callbackfunction returns rand ()%2, and all is sorted !!!

Can be a bug ????


Posted By: angelsoriasanagustin
Date Posted: 08 July 2016 at 4:48am
Sorry !!!! Embarrassed

I have found the problem. I was sorting twice Confused

The function works fine.

Thaks to all !!!!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net