Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - CXTPListBase::SortList Method
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPListBase::SortList Method

 Post Reply Post Reply
Author
Message
angelsoriasanagustin View Drop Down
Groupie
Groupie


Joined: 16 September 2015
Location: Spain
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote angelsoriasanagustin Quote  Post ReplyReply Direct Link To This Post Topic: CXTPListBase::SortList Method
    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.
Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Posted: 15 June 2016 at 2:15am
Hi!

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

:-)
Back to Top
angelsoriasanagustin View Drop Down
Groupie
Groupie


Joined: 16 September 2015
Location: Spain
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote angelsoriasanagustin Quote  Post ReplyReply Direct Link To This Post 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 ????
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2016 at 4:00am
Hello,

You can explore method CXTPShellListBase::SortList

CXTPShellListBase is derived from CXTPListBase.

Regards,
 Oleksandr Lebed
Back to Top
angelsoriasanagustin View Drop Down
Groupie
Groupie


Joined: 16 September 2015
Location: Spain
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote angelsoriasanagustin Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
angelsoriasanagustin View Drop Down
Groupie
Groupie


Joined: 16 September 2015
Location: Spain
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote angelsoriasanagustin Quote  Post ReplyReply Direct Link To This Post Posted: 07 July 2016 at 3:02am
Please... any idea ?
Thanks
Back to Top
cluster View Drop Down
Groupie
Groupie


Joined: 22 January 2015
Status: Offline
Points: 91
Post Options Post Options   Thanks (1) Thanks(1)   Quote cluster Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
angelsoriasanagustin View Drop Down
Groupie
Groupie


Joined: 16 September 2015
Location: Spain
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote angelsoriasanagustin Quote  Post ReplyReply Direct Link To This Post 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 ????
Back to Top
angelsoriasanagustin View Drop Down
Groupie
Groupie


Joined: 16 September 2015
Location: Spain
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote angelsoriasanagustin Quote  Post ReplyReply Direct Link To This Post 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 !!!!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.234 seconds.