ui.ListBox.AddItem()

ui.ListBox.AddItem() creates a new option and adds this option to the list box.

Syntax

CALL <lbx_var>.AddItem("value", "text")

Arguments:

value

value of the list box option = the actual value that will be passed to the corresponding variable when the list box option is selected.

Can be STRING, INTEGER, BOOLEAN, or other type.

text

text of the list 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 list box option as a widget added to the form in Lycia Form Designer.

Compare:

CALL lbx.AddItem("value", "text")

and

You can pass a variable as an argument for ui.ListBox.AddItem() (see example program, ui.ListBox.AddItem_02):

LET option_text = fgl_winprompt(5, 3, "Enter the text for your new list box option.", "", 25, 0)

LET option_value = fgl_winprompt(5, 3, "Enter the value of your new list box option.", "", 25, 0)

IF option_value IS NOT NULL THEN

  CALL lbx.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 list box options (see example program, ui.ListBox.AddItem_01_types):

CALL lbx.AddItem("value", "string")

CALL lbx.AddItem(25, "integer")

CALL lbx.AddItem(TRUE, "boolean")

If you pass a variable as an argument for ui.ListBox.AddItem(), this variable must have the correct data type. Otherwise, a list box option will not be created.

 

If you do not specify text, the list box option will still be created and its text will be the same as the entered value.

If you do not specify value, the list box option will still be created but its value will be NULL.

If you do not specify both text and value, the list box option will still be created but both its properties will be empty:

CALL lbx.AddItem("value", "string")

CALL lbx.AddItem("value", "")

CALL lbx.AddItem("", "string")

CALL lbx.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):

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.