CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2000
    Location
    KL,Malaysia
    Posts
    7

    TreeView Sort bug ?

    after sorting a treeview when we loop through the nodes in code it still follows the original order!!!! any way around it....
    I need to sort the treeview and process in the sorted order...help


    vivek

  2. #2
    Join Date
    May 2001
    Location
    New Jersey, USA
    Posts
    47

    Re: TreeView Sort bug ?

    What do you mean by "sort"?

    Do you mean Node.Sorted = True
    -OR-
    do you have some of your own sorting code?

    if you have a Node.Sorted = True issue
    and want the child nodes in sorted order try something like

    set Nodx = NodeYouSorted.Child
    set Nodx = Nodx.FirstSibling

    Do While Not (Nodx Is Nothing)
    ' we should be moving through the nodes in ascending order now
    List1.AddItem Nodx.Text & " " & Nodx.Index
    Set Nodx = Nodx.Next
    Loop

    The FirstSibling and Next syntax will give you a top down output
    of what you see displayed.






  3. #3
    Join Date
    Nov 2000
    Location
    KL,Malaysia
    Posts
    7

    Re: TreeView Sort bug ?

    thanks.
    Sorted=true,yes.
    It doesnt work if i use a...
    For each node in tree.nodes
    next

    vivek

  4. #4
    Join Date
    May 2001
    Location
    New Jersey, USA
    Posts
    47

    Re: TreeView Sort bug ?

    The problem with the
    For each node in tree.nodes
    next
    syntax is that it's order is set by the Nodes collection in the tree, and will most likely look like the order the Nodes were added to the Tree.

    How many levels deep is your tree?
    It seems that if you want ALL of the Nodes to be part of the sort, that
    a one level deep tree would work for you, more like a List.
    Please email me with info/comments, I'll be happy to help.
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured