KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: The List Box Selection, The List Box variable, and Multiple selection
PRODUCT: 4D | VERSION: 11.4 | PLATFORM: Mac & Win
Published On: June 11, 2009
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

A List Box can have its selection mode set to one of the three following modes:

  1. None means that you cannot select any rows at all.
  2. Single means that only a single row can be selected at any given time.
  3. Multiple means that you can have multiple rows selected at the same time.

In order to check whether or not a row is selected in a List Box that has its selection mode set to Multiple you must check the variable of the List Box itself. Here is the Property List for the List Box we will be using in this example:



The List Box variable is a Boolean array with an element for each item in the List Box. Selected items will show as True, while in contrast unselected items will show as False.

Let's say you have a List Box with a variable named LBox1. In this List Box let's say you have six rows, of those six rows the first and last are unselected while the inner four are selected, as shown here:



Checking the values of the LBox1 array would show the following:

LBox1{1}=False ` first row
LBox1{2}=True ` 2nd row
LBox1{3}=True ` 3rd row
LBox1{4}=True ` 4th row
LBox1{5}=True ` 5th row
LBox1{6}=False ` 6th row


Selected rows are True and unselected rows are False.

Commented by Thomas Fitch on June 15, 2009 at 4:52 PM
This Tech Tip describes a means of handling multiple selections in List Boxes. It also functions perfectly well for single selection List Boxes, though it is not necessary in that case. You can use the GET LISTBOX CELL POSITION command to track the selected row/cell in a single selection List Box. That also works for any type of List Box; not only List Boxes with arrays as the Data Source.
Commented by Charlie Vass on June 12, 2009 at 3:52 PM
The method document in this Tech Tip applies to a list box with a "Data Source" set to Arrays.

If the "Data Source" to the list box is set to "Current Selection", the method to highlight a selection is with the Named Selection as entered in the "Highlight Set" property in the List Box Property List.