Skip to main content
Version: Next

List Box Object

Array list boxes

In an array list box, each column must be associated with a one-dimensional 4D array; all array types can be used, with the exception of pointer arrays. The number of rows is based on the number of array elements.

By default, 4D assigns the name "ColumnX" to each column. You can change it, as well as other column properties, in the column properties. The display format for each column can also be defined using the OBJECT SET FORMAT command.

Array type list boxes can be displayed in hierarchical mode, with specific mechanisms.

With array type list box, the values entered or displayed are managed using the 4D language. You can also associate a choice list with a column in order to control data entry. The values of columns are managed using high-level List box commands (such as LISTBOX INSERT ROWS or LISTBOX DELETE ROWS) as well as array manipulation commands. For example, to initialize the contents of a column, you can use the following instruction:

ARRAY TEXT(varCol;size)

You can also use a list:

LIST TO ARRAY("ListName";varCol)

Warning: When a list box contains several columns of different sizes, only the number of items of the smallest array (column) will be displayed. You should make sure that each array has the same number of elements as the others. Also, if a list box column is empty (this occurs when the associated array was not correctly declared or sized using the language), the list box displays nothing.

Selection list boxes

In this type of list box, each column can be associated with a field (for example [Employees]LastName) or an expression. The expression can be based on one or more fields (for example, [Employees]FirstName+" "[Employees]LastName) or it may simply be a formula (for example String(Milliseconds)). The expression can also be a project method, a variable or an array item. You can use the LISTBOX SET COLUMN FORMULA and LISTBOX INSERT COLUMN FORMULA commands to modify columns programmatically.

The contents of each row is then evaluated according to a selection of records: the current selection of a table or a named selection.

In the case of a list box based on the current selection of a table, any modification done from the database side is automatically reflected in the list box, and vice versa. The current selection is therefore always the same in both places.

Collection or Entity selection list boxes

In this type of list box, each column must be associated to an expression. The contents of each row is then evaluated per collection element or per entity of the entity selection.

Each element of the collection or each entity is available as an object that can be accessed through the This keyword. A column expression can be a property path, a project method, a variable, or any formula, accessing each entity or collection element object through This, for example This.<propertyPath> (or This.value in case of a collection of scalar values). You can use the LISTBOX SET COLUMN FORMULA and LISTBOX INSERT COLUMN FORMULA commands to modify columns programmatically.

When the data source is an entity selection, any modifications made on the list box side are automatically saved in the database. On the other hand, modifications made on the database side are visible in the list box after touched entities have been reloaded.

note

When entities are deleted, their references remain in the entity selection with an undefined value, thus displaying blank rows in the list box. In this case, you can call the .clean() function to get a new entity selection but without the deleted entity references.

When the data source is a collection, any modifications made in the list box values are reflected in the collection. On the other hand, if modifications are done on the collection using for example the various functions of the Collection class, you will need to explicitely notify 4D by reassigning the collection variable to itself, so that the list box contents is refreshed. For example:

myCol:=myCol.push("new value") //display new value in list box

Supported Properties

Supported properties depend on the list box type.

PropertyArray list boxSelection list boxCollection or Entity Selection list box
Alternate Background ColorXXX
Background ColorXXX
BoldXXX
Background Color ExpressionXX
Border Line StyleXXX
BottomXXX
ClassXXX
Collection or entity selectionXX
Column Auto-ResizingXXX
Current itemX
Current item positionX
Data SourceXXX
Detail Form NameX
Display HeadersXXX
Display FootersXXX
Double-click on rowX
DraggableXXX
DroppableXXX
FocusableXXX
FontXXX
Font ColorXXX
Font Color ExpressionXX
Font SizeXXX
Height (list box)XXX
Height (headers)XXX
Height (footers)XXX
Hide extra blank rowsXXX
Hide focus rectangleXXX
Hide selection highlightXXX
Hierarchical List BoxX
Highlight SetX
Horizontal AlignmentXXX
Horizontal Line ColorXXX
Horizontal PaddingXXX
Horizontal Scroll BarXXX
Horizontal SizingXXX
ItalicXXX
LeftXXX
Master TableX
Meta info expressionX
MethodXXX
Movable RowsX
Named SelectionX
Number of ColumnsXXX
Number of Locked ColumnsXXX
Number of Static ColumnsXXX
Object NameXXX
RightXXX
Row Background Color ArrayX
Row Control ArrayX
Row Font Color ArrayX
Row HeightX
Row Height ArrayX
Row Style ArrayX
Selected ItemsX
Selection ModeXXX
Single-Click EditXXX
SortableXXX
Standard actionX
Style ExpressionXX
TopXXX
TransparentXXX
TypeXXX
UnderlineXXX
Variable or ExpressionXX
Vertical AlignmentXXX
Vertical Line ColorXXX
Vertical PaddingXXX
Vertical Scroll BarXXX
Vertical SizingXXX
VisibilityXXX
WidthXXX

List box columns, headers and footers support specific properties.

Supported Form Events

Form eventAdditional Properties Returned (see Form event for main properties)Comments
On After Edit
On After Keystroke
On After SortCompound formulas cannot be sorted.
(e.g., This.firstName + This.lastName)
On Alternative ClickArrays list boxes only
On Before Data Entry
On Before Keystroke
On Begin Drag Over
On Clicked
On Close DetailCurrent Selection & Named Selection list boxes only
On CollapseHierarchical list box only
On Column Moved
On Column Resize
On Data Change
On Delete Action
On Display Detail
On Double Clicked
On Drag Over
On Drop
On ExpandHierarchical list box only
On Footer ClickArrays, Current Selection & Named Selection list boxes only
On Getting FocusAdditional properties returned only when editing a cell
On Header Click
On Load
On Losing FocusAdditional properties returned only when editing a cell has been completed
On Mouse Enter
On Mouse Leave
On Mouse Move
On Open DetailCurrent Selection & Named Selection list boxes only
On Row MovedArrays list boxes only
On Selection Change
On Scroll
On Unload

Additional Properties

Form events on list box or list box column objects may return the following additional properties:

PropertyTypeDescription
areatextList box object area ("header", "footer", "cell")
areaNametextName of the area
columnlongintColumn number
columnNametextName of the column
footerNametextName of the footer
headerNametextName of the header
horizontalScrolllongintPositive if scroll is towards the right, negative if towards the left
isRowSelectedbooleanTrue if row is selected, else False
newPositionlongintNew position of the column or row
newSizelongintNew size (in pixels) of the column or row
oldPositionlongintPrevious position of the column or row
oldSizelongintPrevious size (in pixels) of the column or row
rowlongintRow number
verticalScrolllongintPositive if scroll is towards the bottom, negative if towards the top

If an event occurs on a "fake" column or row that doesn't exist, an empty string is typically returned.