Sample TreeList listview script

From MediaMonkey Wiki
Jump to: navigation, search
' This scripts shows how to use SDBUITreeList control to show and control a grid-like list 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
  VT.HeaderVisible = true
  VT.HeaderAddColumn "Title"
  VT.HeaderAddColumn "Column 2"
  VT.HeaderAddColumn "Column 3"
  VT.HeaderColumnWidth(0) = 150
  VT.HeaderColumnWidth(1) = 120
  VT.HeaderColumnWidth(2) = 120
  VT.RootNodeCount = 10
  VT.ShowTreeLines = false
  VT.Indent = 0
  VT.FullRowSelect = true
  VT.ExtendedFocus = true
  VT.MultiSelect = true
  VT.GridExtensions = true
  VT.ShowRoot = false
  Script.RegisterEvent VT, "OnFocusChanged", "VTFocusChanged"
  Script.RegisterEvent VT, "OnGetText", "VTGetText"

  Form.Common.Visible = True

  SDB.Objects("Form") = Form
End Sub

Sub VTFocusChanged( Node, Column)
  lbl.Caption = Node.Index & " - " & Column
End Sub

Function VTGetText( Node, Column)
  If Column=0 Then
    VTGetText = "Node index: " & node.index
  Else
    VTGetText = "Column " & Column
  End If
End Function