Solved

treeview sort

Posted on 2013-02-07
4
263 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

821 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