Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

treeview sort

Posted on 2013-02-07
4
Medium Priority
?
269 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 1500 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

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 …
As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Viewers will learn the different options available in the Backstage view in Excel 2013.
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…

704 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