Sort list items of a TListView with integer values as captions (Views: 28)
Problem/Question/Abstract: I have an integer value as ListItem caption (using InttoStr). I would like to sort according to the Integer value of these captions. Any Ideas? Answer: function Cussort(Item1, Item2: TListItem; lParamSort: Integer): Integer; stdcall; var I1, I2: Integer; begin I1 := StrToIntDef(Item1.Caption, -1); I2 := StrToIntDef(Item2.Caption, -1); if I1 > I2 then Result := 1 else if I2 < I1 then Result := -1 else Result := 0; end; MyListView.CustomSort(@Cussort, 0); |