With the TreeView, I have it adding children no problem. I also have it able to take a child and make it a sibling of the parent (move up a level in the hierarchy of the family).
However, when I do this, it buggers up how that new sibling is displayed. It displays it all the way to the left instead of in the proper position. I know it is a sibling and not a parent because it collapses when the parent closes.
This is the code to make a child a parent (sibling of the parent), but I haven't found anything in the forum that addresses this issue.
Below are the screen shots showing what I'm talking about. So how do I set the property on a child that has been moved up the hierarchy, to ensure its alignment?
However, when I do this, it buggers up how that new sibling is displayed. It displays it all the way to the left instead of in the proper position. I know it is a sibling and not a parent because it collapses when the parent closes.
This is the code to make a child a parent (sibling of the parent), but I haven't found anything in the forum that addresses this issue.
B4X:
Public Sub MakeParent(objNodeSelected As TreeItem)
If objNodeSelected.IsInitialized = True Then
Dim parentNode As TreeItem = objNodeSelected.Parent
If parentNode.IsInitialized = True Then
Dim grandparentNode As TreeItem = parentNode.Parent
If grandparentNode.IsInitialized = True Then
Dim intIndexOfParent As Int = grandparentNode.Children.IndexOf(parentNode)
Dim intOriginalTreeItemIndex As Int = parentNode.Children.IndexOf(objNodeSelected)
If intIndexOfParent = grandparentNode.Children.Size - 1 Then
grandparentNode.Children.Add(objNodeSelected)
Else
grandparentNode.Children.InsertAt(grandparentNode.Children.IndexOf(parentNode) + 1, objNodeSelected)
End If
parentNode.Children.RemoveAt(intOriginalTreeItemIndex)
End If
End If
End If
End Sub
Below are the screen shots showing what I'm talking about. So how do I set the property on a child that has been moved up the hierarchy, to ensure its alignment?