Moved Up TreeNode becomes unselectable?

0
0

When I move a TreeNode up it becomes unselectable. Why so?

 

Public Function F_Node_Move_Up() As Boolean
Dim OTreeView As TreeView = Me.TreeView
Dim selectedNode As TreeNode = Me
Dim parentNode As TreeNode = selectedNode.Parent

‘ IF tehere is no parent
Dim nodesCollection As TreeNodeCollection
If parentNode Is Nothing Then
nodesCollection = OTreeView.Nodes
Else
nodesCollection = parentNode.Nodes
End If

‘ Find the node index
Dim currentIndex As Integer = nodesCollection.IndexOf(selectedNode)
If currentIndex <= 0 Then
Return False
End If

‘ Moving of the node
nodesCollection.RemoveAt(currentIndex)
nodesCollection.Insert(currentIndex – 1, selectedNode)

‘Select moved node
nodesCollection(currentIndex – 1).EnsureVisible()
Me.TreeView.SelectedNode = nodesCollection(currentIndex – 1)

Return True
End Function

  • You must to post comments
0
0

Hi Mgmst,

Would you please wrap up a small sample for us to check out?

Best Regards,
Alaa

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.