Solved

treeview sort

Posted on 2013-02-07
4
268 Views
Last Modified: 2013-02-12
Can you use SortDirection.Descending for a treeview if so how.
0
Comment
Question by:Seven price
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 19

Accepted Solution

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

Author Comment

by:Seven price
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:Seven price
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:Seven price
ID: 38881973
tks
0

Featured Post

 Database Backup and Recovery Best Practices

Join Percona’s, Architect, Manjot Singh as he presents Database Backup and Recovery Best Practices (with a Focus on MySQL) on Thursday, July 27, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7). In the case of a failure, do you know how long it will take to restore your database?

Question has a verified solution.

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

Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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 create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Suggested Courses

615 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