Forum Discussion
Dmitry_Nikolaev
15 years agoStaff
Hi Karim,
Here is a sample script that demonstrates how to expand the TVirtualStringTree object's nodes:
Sub Main
' This script works with the "<vt contributions>\Examples\Delphi\Minimal\Minimal.exe" sample.
' Before executing the script, add four nodes to the tree making the next node a child of the previous one.
Dim p, wMain, wTree, strItem
Set p = Sys.Process("Minimal")
Set wMain = p.VCLObject("MainForm")
Set wTree = wMain.VCLObject("VST")
strItem = "Level 0, Index 0|Level 1, Index 0|Level 2, Index 0|Level 3, Index 0|Level 4, Index 0"
If clickNode(wTree, strItem) Then
Log.Message "The '" & strItem & "' node was successfully clicked."
End If
End Sub
Function clickNode(wTree, strItem)
Dim tempRes
wTree.FullCollapse(wTree.RootNode)
wTree.ClearSelection
wTree.SetFocusedNode(wTree.RootNode)
Log.LockEvents(1)
tempRes = dblClickNode(wTree, strItem)
Log.UnlockEvents
clickNode = tempRes
If tempRes Then
Log.Event "The '" & strItem & "' node was clicked."
Else
Log.Error "The '" & strItem & "' node was not found."
End If
End Function
Function dblClickNode(wTree, strItem)
Dim wSelected, arrayItem, itemCount, itemId, item
dblClickNode = False
If Len(strItem)= 0 Then
dblClickNode = True
Exit Function
End If
wSelected = wTree.wSelection
arrayItem = Split(strItem, "|")
itemCount = wTree.wItemCount
For itemId = 0 To itemCount - 1
item = wTree.wItem(itemId)
If SameText(item, arrayItem(0)) Then
Call wTree.DblClickItem(wSelected & "|" & arrayItem(0))
arrayItem(0) = ""
dblClickNode = dblClickNode(wTree, Replace(Join(arrayItem, "|"), "|", "", 1, 1))
Exit Function
End If
Next
End Function
Related Content
- 3 years ago
- 13 years ago
- 10 years ago
- 7 years ago
Recent Discussions
- 18 hours ago