Skip to main content
Version: 20

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.

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 Color XXX
Background Color XXX
Bold XXX
Background Color Expression XX
Border Line Style XXX
Bottom XXX
Collection or entity selection XX
Column Auto-Resizing XXX
Current item X
Current item position X
Data Source XXX
Detail Form Name X
Display Headers XXX
Display Footers XXX
Double-click on row X
Draggable XXX
Droppable XXX
Focusable XXX
Font XXX
Font Color XXX
Font Color Expression XX
Font Size XXX
Height (list box) XXX
Height (headers) XXX
Height (footers) XXX
Hide extra blank rows XXX
Hide focus rectangle XXX
Hide selection highlight XXX
Hierarchical List Box X
Highlight Set X
Horizontal Alignment XXX
Horizontal Line Color XXX
Horizontal Scroll Bar XXX
Horizontal Sizing XXX
Italic XXX
Left XXX
Master Table X
Meta info expression X
Method XXX
Movable Rows X
Named Selection X
Number of Columns XXX
Number of Locked Columns XXX
Number of Static Columns XXX
Object Name XXX
Right XXX
Row Background Color Array X
Row Control Array X
Row Font Color Array X
Row Height X
Row Height Array X
Row Style Array X
Selected Items X
Selection Mode XXX
Single-Click Edit XXX
Sortable XXX
Standard action X
Style Expression XX
Top XXX
Transparent XXX
Type XXX
Underline XXX
Variable or Expression XX
Vertical Alignment XXX
Vertical Line Color XXX
Vertical Scroll Bar XXX
Vertical Sizing XXX
Visibility XXX
Width XXX

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
  • column
  • columnName
  • row
  • On After Keystroke
  • column
  • columnName
  • row
  • On After Sort
  • column
  • columnName
  • headerName
  • Compound formulas cannot be sorted.
    (e.g., This.firstName + This.lastName)
    On Alternative Click
  • column
  • columnName
  • row
  • Arrays list boxes only
    On Before Data Entry
  • column
  • columnName
  • row
  • On Before Keystroke
  • column
  • columnName
  • row
  • On Begin Drag Over
  • column
  • columnName
  • row
  • On Clicked
  • column
  • columnName
  • row
  • On Close Detail
  • row
  • Current Selection & Named Selection list boxes only
    On Collapse
  • column
  • columnName
  • row
  • Hierarchical list box only
    On Column Moved
  • columnName
  • newPosition
  • oldPosition
  • On Column Resize
  • column
  • columnName
  • newSize
  • oldSize
  • On Data Change
  • column
  • columnName
  • row
  • On Delete Action
  • row
  • On Display Detail
  • isRowSelected
  • row
  • On Double Clicked
  • column
  • columnName
  • row
  • On Drag Over
  • area
  • areaName
  • column
  • columnName
  • row
  • On Drop
  • column
  • columnName
  • row
  • On Expand
  • column
  • columnName
  • row
  • Hierarchical list box only
    On Footer Click
  • column
  • columnName
  • footerName
  • Arrays, Current Selection & Named Selection list boxes only
    On Getting Focus
  • column
  • columnName
  • row
  • Additional properties returned only when editing a cell
    On Header Click
  • column
  • columnName
  • headerName
  • On Load
    On Losing Focus
  • column
  • columnName
  • row
  • Additional properties returned only when editing a cell has been completed
    On Mouse Enter
  • area
  • areaName
  • column
  • columnName
  • row
  • On Mouse Leave
    On Mouse Move
  • area
  • areaName
  • column
  • columnName
  • row
  • On Open Detail
  • row
  • Current Selection & Named Selection list boxes only
    On Row Moved
  • newPosition
  • oldPosition
  • Arrays list boxes only
    On Selection Change
    On Scroll
  • horizontalScroll
  • verticalScroll
  • 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.

    AltStyle によって変換されたページ (->オリジナル) /