Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / wxListCtrl::SortItems()

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. wxListCtrl::SortItems()
#3332
Posted by: 2004-02-08 08:32:12
I'm  new to wxWindows, but I'm progressing along.  However,  I've come to an impass with respect to sorting items in a wxListCtrl.  The documentaion says that I need to call the method SortItems(wxListCtrlCompare fn, long data) to sort the items.

I need to define the function wxListCtrlCompare with the following prototype
int wxCALLBACK wxListCompareFunction(long item1, long item2, long sortData)

My problem is that I can't seem to figure out how to use the item1, item2 and sortData arguments inside my compare function to do what I want for sorting.  The function provided in the samples does no give me inough info.  All it includes is:

                                                                               
int wxCALLBACK MyCompareFunction(long item1, long item2, long sortData)
{
    // inverse the order
    if (item1 < item2) return -1;
    if (item1 > item2) return 1;
    return 0;
}
                                                                               
I have a wxListCtrl object that I've configured to have several columns in the report view.  I want to be able to sort the items in the wxListCtrl alphabetically based on the values in the 1st column only, the 2nd column only, 3rd column only, etc.  I don't know how to use "item1" and "item2" and "sortData" to obtain the comparison I want in order to return the proper value (-1, 0, or 1) for my function.  All I know is that "itemX" is the "client data" and "NOT the index".  Does any body have any insight into how to do this, or have any sample code I could be directed to to figure this out.  

Thanks for any help you can provide.
John
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Mon 2024-10-7  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0