|
|
|
|
|
- Overview
- Method 1: Using the ListSelect function
- Example
- Method 2: Using the FOR EACH statement
- Example
How to manage a multi-selection in a List Box control?
A List Box control is used to select and retrieve a single element among the available elements. The list is in single-selection. However, you can configure the List Box control so that it becomes multi-selection. In this case, the user will have the ability to select several elements and to retrieve the selected elements programmatically. The "Multiselection" option of the List Box control is available in the "UI" tab of the control qdescription window. The user can perform a multi-selection via the standard Shift and Ctrl keys, the arrows and/or the mouse. Two methods can be used to retrieve the selected elements: Method 1: Using the ListSelect function This method consists in performing a browse loop with ListSelect. A variable representing the rank of the selected element will be incremented from the value 1. - If ListSelect returns -1: there is no or no longer any element selected.
- If ListSelect returns a value greater than 0: this value represents the position of the item selected in the List Box control.
To retrieve the value of the selected element, use the following syntax: NameListBoxControl[Subscript] Note: You can find out the number of items selected using the ListSelectCount function. This allows you to perform a loop with a FOR statement instead of a WHILE statement. Example Rank is int
ElementPosition is int
ElementValue is string
Rank = 1
ElementPosition = ListSelect(ListName, Rank)
WHILE ElementPosition<>-1
ElementValue = ListName[ElementPosition]
Rank++
ElementPosition = ListSelect(ListName, Rank)
END
Method 2: Using the FOR EACH statement This method is used to browse the list of selected elements with a specific FOR EACH statement. Example ElementValue is string
FOR EACH SELECTED ROW OF ListName
ElementValue = ListName.DisplayedValue
END
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|