ui.ListBox methods are used to manipulate ui.ListBox objects at runtime.
To manipulate ui.ListBox objects, you have to:
declare the ui.ListBox object with a DEFINE statement:
DEFINE lbx_object ui.ListBox
initialize the ui.ListBox object:
LET lbx_object = ui.ListBox.forName("my_listbox")
There are two groups of methods available for list boxes - methods that allow changing the content of a list box and methods that allow changing its properties.
Methods for changing the content of a list box
creates an object of the ui.ListBox class: LET lbx= ui.ListBox.Create("f1") |
|
initializes the object of the ui.ListBox class: LET lbx= ui.ListBox.ForName("f1") |
|
adds a new option to the list box: CALL lbx.AddItem("added","new") CALL lbx.AddItem(option_value,option_text) |
|
deletes an option from the list box: CALL lbx.RemoveItem("value") CALL lbx.RemoveItem(remove_option) |
|
removes all the options from the list box: CALL lbx.Clear() |
|
returns the number of options in the list box: DISPLAY lbx.GetItemCount() |
|
returns the value of the list box option: DISPLAY lbx.GetItemName(4) DISPLAY lbx.GetItemName(input_var) |
|
returns the text of the list box option: DISPLAY lbx.GetItemText(4) DISPLAY lbx.GetItemText(input_var) |
|
returns the text of the list box option: DISPLAY lbx.GetTextOf("value") DISPLAY lbx.GetTextOf(value_var) |
|
returns the index of the list box option: DISPLAY lbx.GetIndexOf("value") DISPLAY lbx.GetIndexOf(value_var) |
|
getTag() |
returns the identifier of the list box |
Methods for changing the properties of a list box
allows selecting several options at a time: CALL lbx.setSetEnableMultiSelection(1) CALL lbx.setSetEnableMultiSelection(TRUE) |
|
getEnableMultiSelection() |
returns whether it is allowed to select several options at a time |
renames the list box options: CALL lbx.SetListBoxValues("new_option") CALL lbx.SetListBoxValues(["new_option1","new_option2","new_option3"]) |
|
getListBoxValues() |
returns the text of all list box options |
selects one or more list box option: CALL lbx.setSelectedItems(1) |
|
getSelectedItems() |
returns the index of the selected items (both selected manually and from the 4gl code) |
setHelperText() |
sets the helper text for the list box (material design): CALL lbx.SetHelperText("helperText") |
getHelperText() |
returns the helper text for the list box (material design): |