我有一个树视图,它实现了 2 种类型的项目、文件夹和项目。当我对它们进行排序时,我希望这些项目出现在文件夹下方
喜欢
folder a
subfolder a
subitem z
folder b
item a
item b
如何修改我的排序例程?
Public Class ascsorter
Implements Collections.IComparer
Public Function Compare(ByVal x As Object, ByVal y As Object) _
As Integer Implements Collections.IComparer.Compare
Dim tx As Windows.Forms.TreeNode = CType(x, Windows.Forms.TreeNode)
Dim ty As Windows.Forms.TreeNode = CType(y, Windows.Forms.TreeNode)
Return -String.Compare(tx.Text, ty.Text)
End Function
End Class
Public Class descsorter
Implements Collections.IComparer
Public Function Compare(ByVal x As Object, ByVal y As Object) _
As Integer Implements Collections.IComparer.Compare
Dim tx As Windows.Forms.TreeNode = CType(x, Windows.Forms.TreeNode)
Dim ty As Windows.Forms.TreeNode = CType(y, Windows.Forms.TreeNode)
Return String.Compare(tx.Text, ty.Text)
End Function
End Class