I am populating a tree view dynamically so I do not know the amount of levels I may have.
Is there a way to rollback to the previous level? Here is a sample of my code:
Private Sub RecursiveTreeAssembly(FileName As String, node As TreeNodeCollection)
'Sets sFileNamePath to correct path value
FileNameToFilePath(FileName)
'Start SolidEdge
StartSolidEdge()
'Open document
OpenSolidEdgeDocument(sFileNamePath)
'Get the parts list for the opened document (FileName)
partList = clsPartInformation.GetAll()
'Populate tree View
If partList.Count > 0 Then
'PartsList retrieved, close document
CloseSolidEdgeDocument(FileName)
'Go through all part lists and display them in tree view
For i As Integer = 0 To partList.Count - 1
'Is it Assembly, Parametric, Material, Part to buy
If IsAssembly(partList(i).Part_No) Then
node(iterator).Nodes.Add(partList(i).Part_No)
ElseIf IsMaterial(partList(i).Part_No) Then
node(iterator).Nodes.Add(partList(i).Part_No)
ElseIf IsPart(partList(i).Part_No) Then
node(iterator).Nodes.Add(partList(i).Part_No)
End If
tvDessins.ExpandAll()
Next
End If
'Go through tree view to populate it
While iterator < tvDessins.Nodes(0).Nodes.Count
If rollback Then
node = tvDessins.Nodes
currFileName = node(0).Nodes.Item(iterator).Text
Else
currFileName = node(iterator).Nodes.Item(0).Text
End If
If IsAssembly(currFileName) Then
rollback = False
'Call itself again
RecursiveTreeAssembly(currFileName, node(0).Nodes)
Else
'Rollback nodes
rollback = True
End If
iterator += 1
End While
End Sub
tvDessin is my tree view. In the following code, I will iterate through a tree view that has been given some items recursively. My parts list contains the part number, that works great.
It is during my rollback that I set the tree nodes to the beginning:
node = tvDessins.Nodes
Instead of simply going to the parent node … That’s what I’m looking to achieve!
Thank you, sorry for such a long post.
I figured it out.
Here’s the answer: