Sample TreeList tree script
		
		
		
		Jump to navigation
		Jump to search
		
' This scripts shows how to use SDBUITreeList control to show and control a tree of items. 
Dim lbl, VT
Sub OnStartUp()
  Dim Form
  Set Form = SDB.UI.NewForm
  Form.Common.SetRect 100, 100, 500, 440
  Form.BorderStyle = 3
  Form.FormPosition = 4
  Form.StayOnTop = True
  Form.Caption = "Test"
  Set lbl = SDB.UI.NewLabel(Form)
  lbl.Common.SetRect 10, 10, 400, 15
  Set VT = SDB.UI.NewTreeList(Form)
  VT.Common.SetRect 10, 30, 400, 300
  Set node = VT.AddNode(Nothing)
  node.UserText = "My first parent"
  Set node2 = VT.AddNode(Nothing)
  node2.UserText = "My second parent"
  Set node3 = VT.AddNode(node)
  Set node4 = VT.AddNode(node)
  node3.CheckType = 3
  node4.CheckType = 3
  node4.CheckState = 1
  node.Expanded = True
  Set node5 = VT.AddNode(node2)
  node5.CheckType = 2
  Script.RegisterEvent VT, "OnFocusChanged", "VTFocusChanged"
  Script.RegisterEvent VT, "OnExpanding", "VTExpanding"
  Script.RegisterEvent VT, "OnGetText", "VTGetText"
  Set Btn = SDB.UI.NewButton(Form)
  Btn.Common.SetRect 10, 350, 80, 25
  Btn.Caption = "Add sublevel"
  Script.RegisterEvent Btn, "OnClick", "BtnClick"
  Form.Common.Visible = True
  SDB.Objects("Form") = Form
End Sub
Sub VTFocusChanged( Node, Column)
  lbl.Caption = Node.Index & " - " & Column
End Sub
Sub VTExpanding( Node)
  VT.AddNode( node)
  VT.AddNode( node)
  VT.AddNode( node)
End Sub
Function VTGetText( Node, Column)
  If node.UserText<>"" Then
    VTGetText = node.UserText
  Else
    VTGetText = "Node index: " & node.index
  End If
End Function
Sub BtnClick
  VT.FocusedNode.HasChildren = True
  VT.Invalidate
End Sub