### Pass an Array to a Form

To pass an array of string to a form, following example.
The array of strings are shown in a listview of a sub form.
The sub form is called by a mainform with the array of strings as parameter.
Define the Class Module
'Class module stored in the Project Folder
`Sub Class_Globals
Private fx As JFX
Private frm As Form
Private lvwItems As ListView
Private lblItem As Label
End Sub`
'Initializes the object.
`Public Sub Initialize(Items() As String)
' Init the form. Form size is set to best size
frm.Initialize("frm", -1, -1)
' Give the form a title and make it a utility form (toolbox type of form)
frm.title = "TestClass"
frm.SetFormStyle("UTILITY")
' Load the layout - simple form with only one multiline label with wordwrap set
frm.RootPane.LoadLayout("TestClass")
' Populate the listview
lvwItems.Items.AddAll(Items)
End Sub`
' Show the form. A result can be set. In this case using an integer (my year of birth = just to test)
`Public Sub Show As Int
frm.ShowAndWait
Return 1958
End Sub`
' Close the form
`Sub frm_CloseRequest (EventData As Event)
' Log("Form closed via close request")
End Sub`
`Sub lvwItems_SelectedIndexChanged(Index As Int)
If Index <> -1 Then
lblItem.Text = lvwItems.Items.Get(Index)
End If
End Sub`
Layout Nodes
Label lblItem
ListView lvwItems
MainForm Button which calls the Sub Class
`Sub buttonTest_Action
Dim tc As TestClass
Dim items() As String = Array As String("Item 1", "Item 2", "Item 3")
tc.Initialize(items)
tc.Show
End Sub`

Changed: , Category: Forms, File: T6C195M1424.htm, ID: 1424