如果sorttyp = stData,说明是要你自己在Oncompare事件里写代码自己排序,不一定是根据data指针链接的数值排序,可以是根据任何可以比较大小的数据进行排序。

解决方案 »

  1.   

    可怎么写呢?
    procedure TfrmXgTest.ListView1Compare(Sender: TObject; Item1,
      Item2: TListItem; Data: Integer; var Compare: Integer);data是什么?
    返回的应该是compare吧?可值应该是怎样的?
      

  2.   

    if Compare<Data then
      Compare:=Data;
      

  3.   

    你能看一下OnCompare的帮助吗?
    when OnCompare occurs in response to the AlphaSort method, the Data parameter is 0. When OnCompare occurs in response to the CustomSort method, the Data parameter is the value of the LParam parameter of CustomSort.
    如果用户调用了AlphaSort,那么data是0,如果调用了CustomSort,data是在CustomSort里指定的LParam参数的值。If Item1 is the same as Item2 in the sort order, set the Compare parameter to 0. If Item1 is less than Item2, set the Compare parameter to a value less than 0. If Item1 is greater than Item2, set the Compare parameter to a value greater than 0. 
    你可以通过把Compare设置为>0,=0 ,<0来决定Item1、item2如何排序。
    在OnCompare的帮助里有例子。