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
-
Problem with migration to C# (CoCreateInstanceEx)
by LRollison (1 replies)
-
VB6 Problem Creating Shortcuts
by rb1177 (0 replies)
-
how can i open a file
by kyawswarhtun (0 replies)
-
how to save any one form what i want?
by blackguy (5 replies)
-
Build an MP3 Player
by soybees (4 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.