Which Control for a vbScript Multi-Column ListBox?

Post a reply

Visual Confirmation

To prevent automated access and spam, you are required to confirm that you are human. Please place a check mark next to all images of monkeys or apes. If you cannot see any images, please contact the Board Administrator.

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: Which Control for a vbScript Multi-Column ListBox?

Re: Which Control for a vbScript Multi-Column ListBox?

Post by Thanasis » Sun Oct 16, 2011 11:55 pm

Dearest Eval,

That worked perfectly.... Thank you so much mate. I really appreciate your time.

The Array and Refresh methods you suggested are perfect..... and really what I wanted....

I am writing a very cool extension that I am about to share with you here......

Thank you again....

Re: Which Control for a vbScript Multi-Column ListBox?

Post by Eyal » Sun Oct 16, 2011 10:23 pm

Hi Thanasis,

I never used this control, but as I understand it, VTGetText() is only executed on first initialization of the SDBUITreeList control, and when Refresh method is used.

Thus I thing the easiest would be to initially fill the data to display in an array, and call the Refresh method on subsequent changes.

Example:

Code: Select all
Dim lbl, VT, GridData(10,3)

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
  '------------------------
  'Fill Grid data:
  GridData(0,0) = "text 1"
  GridData(0,1) = "text 2"
  GridData(1,2) = "text 3"
  GridData(4,1) = "text 4"
  GridData(7,0) = "100"
  GridData(9,2) = "2000"
  '------------------------ 
  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 IsEmpty(GridData(Node.index, Column)) Then
        VTGetText = ""
    Else
        VTGetText = GridData(Node.index, Column)
    End If       
End Function


:~)

Re: Which Control for a vbScript Multi-Column ListBox?

Post by Thanasis » Sun Oct 16, 2011 1:16 pm

I found a code in MM WIKI, but I have a problem still, that I can not add my own text to the fields of the list....... Any ideas please? :

Code: Select all
' 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

Which Control for a vbScript Multi-Column ListBox?

Post by Thanasis » Thu Oct 13, 2011 2:28 am

I am looking for the Class Class / object / Control in vbScript that creates a Listbox with Columns in the Options Sheet, just like the one we see in Options/DSP or General Plug-Ins.

Normally we create a ListBox using the followng code
Code: Select all
Sub OnStartup
   ' Create our own option sheet
   SDB.UI.AddOptionSheet "My AddOn", Script.ScriptPath, "InitSheet", "", -2
End Sub

Sub InitSheet( Sheet)
   Set UI=SDB.UI
  Set lb1 = UI.NewListBox( Sheet)
  lb1.Common.SetRect 20, 110, 240, 220
  lb1.Common.ControlName = "ListBox"
End Sub



I am just trying to find a way to add columns to my list box in the options sheet just like the following picture:

Image

Free beer for the person who gives me the hint. Just the name of the Control. NOTHING MORE !!!!

Top