我有一个包含多列的ListView(GridView),到目前为止,我可以按字母顺序对其进行排序,但是当我对A-Z进行排序时,空字符串会显示在顶部。我想将这些移到最后。我想我已经设法制作了一个IComparer,它会在最后放置空字符串,但我不知道如何使我的ListView使用它。顺便说一下,这是我做的比较器:
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
If TypeOf x Is String And TypeOf y Is String Then
If x = "" And y = "" Then
Return 0
ElseIf x = "" And y <> "" Then
Return 1
ElseIf x <> "" And y = "" Then
Return -1
End If
End If
Return x.CompareTo(y)
End Function
答案 0 :(得分:1)
检查一下。您可以在IComparer类型的自定义排序器中连接,就像您尝试这样做: http://ligao101.wordpress.com/2007/07/31/a-much-faster-sorting-for-listview-in-wpf/