ListBox class

A ListBox is a simple list of selectable items.

To create a list box use the wb_create_control() function using ListBox as the class parameter.

Creating list boxes

// Create an empty list box

wb_create_item($window, ListBox, "", 10, 10, 100, 90, ID_LIST);

After creating the list box, you can assign values to the control in several ways:

1) By creating an array to store the item names and using wb_set_text() to assign them to the control:

$a_list = array("Line1", "Line2", "Line3", "Line4");

// Assign values to list box control
wb_set_text(wb_get_control($window, ID_LIST), $a_list);

2) By assigning it a string with items separated by a line break (\n) or line feed/line break sequence: (\r\n):

$s_list = "Line1\nLine2\nLine3";       \\ Or "Line1\r\nLine2\r\nLine3"

// Assign values to list box control
wb_set_text(wb_get_control($window, ID_LIST), $s_list);

3) By including the desired items when creating a control:

wb_create_item($window, ListBox, "Line1\nLine2\nLine3", 10, 10, 100, 90, ID_LIST);

Setting and retrieving information

To associate an integer value with a given item, use wb_set_value(). Set item to the desired item index, or leave it blank (or set it to -1) to associate the value to the currently selected item.

To retrieve the index of the currently selected item, call wb_get_selected(). Use wb_get_value() to retrieve the integer value associated to the specified item, or leave item empty (or set it to -1) to retrieve the value of the currently selected item.

See also

wb_create_control
wb_get_selected
wb_get_value
wb_set_text
wb_set_value
ComboBox class
Control classes