Solved

treeview sort

Posted on 2013-02-07
4
257 Views
Last Modified: 2013-02-12
Can you use SortDirection.Descending for a treeview if so how.
0
Comment
Question by:sevensnake77
  • 3
4 Comments
 
LVL 19

Accepted Solution

by:
Manoj Patil earned 500 total points
ID: 38865306
0
 
LVL 9

Author Comment

by:sevensnake77
ID: 38877955
These did not help I am trying to sort instead of ascending to descending.
I tryied both links implement the code nothing.
0
 
LVL 9

Author Comment

by:sevensnake77
ID: 38878095
this almost seem to work but only with 2 nodes with 3 doesn't work.
  Private Sub SortTreeNodes(treeNodes As TreeNodeCollection)
        Dim sorted = True

        For Each treeNode As TreeNode In treeNodes
            SortTreeNodes(treeNode.ChildNodes)
        Next

        Do
            sorted = True

            For i = 0 To treeNodes.Count - 1
                Dim treeNode1 = treeNodes(i)
                Dim treeNode2 = treeNodes(i)
                Dim treeNode3 = treeNodes(i + 1)

                ' If treeNode1.Text.CompareTo(treeNode3.Text) < 0 Then
                treeNodes.RemoveAt(i)
                treeNodes.RemoveAt(i)
                treeNodes.RemoveAt(i)

                treeNodes.AddAt(i, treeNode1)
                treeNodes.AddAt(i, treeNode2)
                treeNodes.AddAt(i, treeNode3)

                Response.Write(i)
                '   End If
            Next
        Loop While Not sorted
    End Sub

Open in new window

0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 38881973
tks
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now