У меня есть дерево, которое реализует 2 типа предметов, папок и предметов. Когда я сортирую их, я хочу, чтобы элементы появляются ниже папки.NET treeview сортировать по алфавиту по типу узла
как
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
Да, я использую свойство 'Tag' для тонны таких вещей. tx, мне потребовалось бы много времени, чтобы выяснить это простое решение – aelgoa