PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in ..../includes/geshi.php on line 2147

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2010 Moving a TreeView node up/down at run-time?-VBForums
Results 1 to 9 of 9
  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    126

    Moving a TreeView node up/down at run-time?

    Hey guys,

    Spent most of the day yesterday trying to figure this out but no luck so far. I would have thought that there would be an easy way to do this, but after spending hours Google'ing the subject, I could not find a single working example to accomplish this.

    Anyways, here's what I'm trying to do...

    I have a tree view with up/down buttons. The up/down buttons should move the selected node up or down in relation to the other nodes.

    For example, if the nodes in the tree view start out in this order...

    Node1
    Node2
    Node3

    ... then if the user selects 'Node2' and clicks the 'Down' button, the nodes should then be in this order...

    Node1
    Node3
    Node2

    Simple, right? It would be simple if the node's 'index' property was not read-only. If that was the case, then I could just do something like this...

    Code:
    Private Sub UpButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpButton.Click
    
            TreeView1.SelectedNode.Index = TreeView1.SelectedNode.Index - 1
    
        End Sub
    
        Private Sub DownButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownButton.Click
    
            TreeView1.SelectedNode.Index = TreeView1.SelectedNode.Index + 1
    
        End Sub
    But the 'Index' property is read-only, so I have no clue how to accomplish this (nor does anyone on the first 5 pages of Google search results, lol).

    Any ideas?

  2. #2
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,464

    Re: Moving a TreeView node up/down at run-time?

    you will probably need to build a second tree that takes the place of the first when complete

    just a thought

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    126

    Re: Moving a TreeView node up/down at run-time?

    Quote Originally Posted by incidentals View Post
    you will probably need to build a second tree that takes the place of the first when complete

    just a thought
    Not sure I'm following your logic there. What would be the point of building a 2nd tree?

  4. #4
    Member
    Join Date
    Aug 2004
    Location
    Sao Paulo / Brazil
    Posts
    38

    Re: Moving a TreeView node up/down at run-time?

    Hi,
    here is me code for a ListView, its almost the same as the treeview (just uses the same level)

    Code:
        Public Sub UpSelected()
    
            If Me.SelectedItems.Count = 0 Then
                Exit Sub
            End If
    
            If Me.SelectedIndices(0) = 0 Then
                Me.Focus()
                Exit Sub
            End If
    
            Dim NewItem As ListViewItem = CType(Me.SelectedItems(0).Clone, ListViewItem)
            Dim PreviousItem As ListViewItem = CType(Me.Items(Me.SelectedIndices(0) - 1), ListViewItem)
    
            Me.Items.Insert(Me.SelectedIndices(0) - 1, NewItem)
            Me.SelectedItems(0).Remove()
            NewItem.Selected = True
    
            Me.Focus()
    
        End Sub
    
        Public Sub DownSelected()
    
            If Me.SelectedItems.Count = 0 Then
                Exit Sub
            End If
    
            If Me.SelectedIndices(0) + 1 >= Me.Items.Count Then
                Me.Focus()
                Exit Sub
            End If
    
            Dim NewItem As ListViewItem = CType(Me.SelectedItems(0).Clone, ListViewItem)
            Dim PreviousItem As ListViewItem = CType(Me.Items(Me.SelectedIndices(0) + 1), ListViewItem)
    
            Me.Items.Insert(Me.SelectedIndices(0) + 2, NewItem)
            Me.SelectedItems(0).Remove()
            NewItem.Selected = True
    
            Me.Focus()
    
        End Sub
    --------------------------------------
    All your base are belong to us.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    126

    Re: Moving a TreeView node up/down at run-time?

    Thanks for the example cbuosi, but I have no idea how to apply that to a tree view.

    I would have thought that moving a node up or down would be something that a lot of people would want to do with a tree view control. Strange that there does not appear to be a simple way to do it.

  6. #6
    New Member
    Join Date
    Dec 2017
    Posts
    3

    Re: Moving a TreeView node up/down at run-time?

    Quote Originally Posted by BMAN645 View Post
    Thanks for the example cbuosi, but I have no idea how to apply that to a tree view.

    I would have thought that moving a node up or down would be something that a lot of people would want to do with a tree view control. Strange that there does not appear to be a simple way to do it.
    It's an old post, but are there answers on this? I searched the site but couldn't find anything. I suppose the idea would be to move the bottom-most displayed treeview node to the top of the display to move down, and to move the top-most displayed node to the bottom to go up a page. I've scoured the web for a code sample but no joy...

  7. #7
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,527

    Re: Moving a TreeView node up/down at run-time?

    Start new project, add Button1, Button2 and TreeView1 then Paste the following code

    vb.net Code:
    1. span style="color: #808080;">"."' Move root
    2. ' Move root



  8. #8
    New Member
    Join Date
    Dec 2017
    Posts
    3

    Re: Moving a TreeView node up/down at run-time?

    4x2y- Thanks for the quick response!

    One other thing I'm trying to do (not the same as the original thread so I might start a new one).

    I have a treeview where I'm trying to provide forward and back buttons, so that the displayed portion of the treeview will page forward or backwards. This would be an alternative way to page through a large treeview as opposed to using the vertical scroll bar. I didn't see any methods associated with moving the displayed portion of the treeview.

    Any ideas?

  9. #9
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,527

    Re: Moving a TreeView node up/down at run-time?

    TreeView is showing hierarchic structure, I can't imagine how it can can be splitted into pages as you describe!

    Please open new thread



Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width