Populate a list at run time
- Last Updated: April 30, 2024
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
There are two methods you can use on a selection list, combo box, or radio set to set the value
list at run time: ADD-FIRST and ADD-LAST. Each has the
same two forms:
|
Use ADD-FIRST to add items to the beginning of the list and
ADD-LAST to add them to the end. If the object uses the simple
List-Items form, in which the actual object values are
displayed, then use the item-list form of the method to add one or
more items to the list. If the object uses the List-Item-Pairs
form, then use the second form of the method to specify a single label followed by the
single value it represents.
These types of objects have a DELIMITER attribute to allow you to set a
delimiter between items other than the default comma, in case one of the values or
labels contains a comma.
The objects also support a logical SORT attribute, which initially is
false. If you set SORT to true, then displayed items are sorted by
their label. In this case, there is no meaningful difference between using
ADD-FIRST and ADD-LAST.
The methods return true if the operation succeeded, and false if for any reason it failed.
To use the ADD-LAST method to add each of the OrderLine field names to the end of the selection list:
- Enter this code to complete the
initSelectionprocedure:/*--------------------------------------------------------------------- Purpose: Set the selection list to a list of all the fields in the OrderLine table. Parameters: <none> ---------------------------------------------------------------------*/ DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO. DEFINE VARIABLE iFields AS INTEGER NO-UNDO. hBuffer = BUFFER OrderLine:HANDLE. DO WITH FRAME CustQuery: DO iFields = 1 TO hBuffer:NUM-FIELDS: OLineFields:ADD-LAST(hBuffer:BUFFER-FIELD(iFields):NAME). END. END. END PROCEDURE. - To display these values in the list when the window is viewed, add a
RUNstatement to the procedure’s main block:MAIN-BLOCK: DO ON ERROR UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK: RUN enable_UI. RUN h-StartSuper.p("h-dynsuper.p"). RUN changeFields. RUN initSelection. IF NOT THIS-PROCEDURE:PERSISTENT THEN WAIT-FOR CLOSE OF THIS-PROCEDURE. END.