skip to main content

Controls Reference : LIST-BOX : Properties : Data-Columns

Data-Columns
The data in a row of the List-Box can be set or retrieved using a single alphanumeric or a group variable. This property describes the starting position of information in that variable for each column, beginning at 1. The ending position cannot be directly set: it is always the character before the first character of the next column.
We can suppose, for example, to have a three-column List-Box with the following headers: First Name, Last Name, Address. The buffer necessary to add data to the list-box should be structured like this:
01  List-Box-Data.
    03 First_Name pic x(20).
    03 Last_Name  pic x(30).
    03 Address    pic x(50).
The DATA-COLUMNS property should be set as follows:
DATA-COLUMNS = (1, 21, 51)
Instead of hard-coded values, it is possible to use the RECORD-POSITION syntax:
DATA-COLUMNS = (RECORD-POSITION OF First_Name, 
                RECORD-POSITION OF Last_Name, 
                RECORD-POSITION OF Address)
This syntax avoids problems due to the modification of the item size in the buffer.
When using standard alphanumeric items, the offset of data columns is calculated in bytes, not in digits, so you should pay attention if you’re using a variable length encoding (e.g. UTF-8) to store data in the List-Box record buffer.
When using national items, you can’t take advantage of the RECORD-POSITION syntax. You need to use values calculated on the items length in digits, For example, for the following group item:
01  List-Box-Data USAGE-GROUP NATIONAL.
    03 First_Name pic N(20).
    03 Last_Name  pic N(30).
    03 Address    pic N(50).
the correct DATA-COLUMNS setting is:
DATA-COLUMNS = (1, 21, 51)
and not (1, 41, 101) as RECORD-POSITION would return.
 
Example - Set data columns by reading values from a Occurs
procedure division.
modify screen-1-lb-1, data-columns = -1 | resets the list of values
perform varying columnidx from 1 by 1 until columnidx > columncount
   modify screen-1-lb-1, data-columns = w-data-col(columnidx) 

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left