HI,
How to retrieve data from UltraTreeview?
i tried the below code. It is not working 'due to 'Object reference not set to an instance' error.
' Declare variables for tree Dim CdTree As ITestDataTree Dim CdTreeNodes As ITestDataTreeNodes Dim CdTreeNode() As ITestDataTreeNode ' Variables to hold tree data CdTree = Tree2().GetTestData("TreeView") CdTreeNodes = CdTree.GetTreeNodes() - ----- "Error at this line 'Object reference not set to an instance of an object'" CdTreeNode = CdTreeNodes.GetRootNodes()
' Print out total number of nodes
MsgBox("Tree Total Node Count: " + CdTreeNodes.GetNodeCount())
MsgBox(
"Tree Root Node Count : " + CdTreeNodes.GetRootNodeCount())
' Iterate through tree branches; this is a recursive method. Dim I As Integer For I = 0 To CdTreeNode.Length - 1 ShowTree(CdTreeNode(I), 0) Next I
Thanks in advance. Rekha.
Hi Rekha,
Try this code: (if you want to iterate through all nodes recursively then you need to implement the "ShowTree" recursive method)
Dim CdTree As ITestDataTree
Dim CdTreeNodes As ITestDataTreeNodes
Dim CdTreeNode() As ITestDataTreeNode
' Variables to hold tree data
CdTree = Tree2().GetTestData("all tree data")
CdTreeNodes = CdTree.GetTreeNodes()
CdTreeNode = CdTreeNodes.GetRootNodes()
MsgBox("Tree Total Node Count: " + CdTreeNodes.GetNodeCount().ToString())
MsgBox("Tree Root Node Count : " + CdTreeNodes.GetRootNodeCount().ToString())
' loop through the tree root bands
Dim I As Integer
For I = 0 To CdTreeNode.Length - 1
LogInfo(CdTreeNode(I).GetNode().ToString())
Next I
Regards,
Ammar
Hi Ammar,
Here we have child nodes as shown in the attached file. so i called showTree() method:
Public Sub ShowTree(ByVal Node As ITestDataTreeNode, ByVal_Indent As Integer)
IIf(Indent < Tabs.Length(), TabCount = Indent, TabCount = Tabs.Length())
Dim Children() As ITestDataTreeNode = Node.GetChildren()
Dim ChildCount As Integer
IIf(ChildCount <> 0, ChildCount = Children.Length, ChildCount = 0)
For I = 0 To ChildCount - 1 Next
ShowTree(Children(I), Indent + 1)
End Sub
But i'm unable to get the child data. and in childcount it is returning 0 which is wrong.
Rekha.