ui.ComboBox.AddItem() creates a new option and adds this option to the combo box.
Syntax
CALL <cmb_var>.AddItem("value", "text")
Arguments
value |
value of the combo box option = the actual value that will be passed to the corresponding variable when the combo box option is selected. |
text |
text of the combo box option = the text end-users will see as the option they can choose |
Usage and examples
Takes two arguments - value and text - that correspond to the same properties of a combo box option as a widget added to the form in Lycia Form Designer.
Compare:
CALL cmb.AddItem("value", "text")
and
You can pass a variable as an argument for ui.Combobox.AddItem() (see example program, ui.ComboBox.AddItem_02):
LET option_text = fgl_winprompt(5, 3, "Enter the text for your new combo box option.", "", 25, 0)
LET option_value = fgl_winprompt(5, 3, "Enter the value of your new combo box option.", "", 25, 0)
IF option_value IS NOT NULL THEN
CALL cmb.AddItem(option_value, option_text)
END IF
text is always either a character string or a variable of STRING data type.
value can be STRING, INTEGER, BOOLEAN, or of other type that is available for combo box options (see example program, ui.ComboBox.AddItem_01_types):
CALL cmb.AddItem("value", "string")
CALL cmb.AddItem(25, "integer")
CALL cmb.AddItem(TRUE, "boolean")
If you do not specify text, the combo box option will still be created and its text will be the same as the entered value.
If you do not specify value, the combo box option will still be created but its value will be NULL.
If you do not specify both text and value, the combo box option will still be created but both its properties will be empty:
CALL cmb.AddItem("value", "string")
CALL cmb.AddItem("value", "")
CALL cmb.AddItem("", "string")
CALL cmb.AddItem("", "")
Leading and trailing spaces are treated differently for text and value.
For text, both leading and trailing spaces are truncated:
For value, both leading and trailing spaces are preserved (= not truncated):