Library code snippets
Treeview Reverse Sorting
By Kym Manson, published on 19 Mar 2002
you may have a treeview like this:
Main Node
+ The Parent
| - A
| - B
| - C
| - D
This routine will sort Z-A
so the result should be
Main Node
+ The Parent
| - D
| - C
| - B
| - A
Main Node
+ The Parent
| - A
| - B
| - C
| - D
This routine will sort Z-A
so the result should be
Main Node
+ The Parent
| - D
| - C
| - B
| - A
Private Sub Command1_Click()
Dim tvn As Node
Dim tvn2 As Node
sName = 1 ' Change Node 1
' or sName = "MyNodeName"
Set tvn = TreeView1.Nodes(sName)
tvn.Sorted = True ' firstly sort A-Z then we simply replace last items with the first ones
tvn.Sorted = False
chil = tvn.Children: If chil = 0 Then Exit Sub ' if no children the exit
Set tvn = tvn.Child.LastSibling
For a = 1 To chil
Set tvn2 = tvn
Set tvn = tvn.Previous
TreeView1.Nodes.Remove tvn2.Index
TreeView1.Nodes.Add sName, 4, tvn2.Key, tvn2
Next
End Sub
Related articles
Related discussion
-
Run-time error '91'
by converter2009 (1 replies)
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
This thread is for discussions of Treeview Reverse Sorting.