For instance, the documentation for the COMBO-BOX phrase contains an example of populating a combo-box from a database table:
Code:
DEFINE VARIABLE ix AS INTEGER NO-UNDO.
DEFINE VARIABLE rep AS CHARACTER NO-UNDO LABEL "Rep" VIEW-AS COMBO-BOX.
DEFINE VARIABLE temp-string AS CHARACTER NO-UNDO.
FORM rep WITH FRAME main-frame SIDE-LABELS.
ON ANY-PRINTABLE OF rep DO: /* Find the first entry in the drop‑down list that begins with the character typed. Set the SCREEN-VALUE of the combo box to that value. */
seek-item: DO ix = 1 TO SELF:NUM-ITEMS:
IF SELF:ENTRY(ix) BEGINS LAST-EVENT:FUNCTION THEN DO:
SELF:SCREEN-VALUE = SELF:ENTRY(ix).
LEAVE seek-item.
END.
END.
IF ix > SELF:NUM-ITEMS THEN BELL.
END.
ON CURSOR-DOWN OF rep DO: /* Change the SCREEN-VALUE of the combo box to the next value from the drop‑down list. */
ix = SELF:LOOKUP(SELF:SCREEN-VALUE).
IF ix < SELF:NUM-ITEMS THEN
SELF:SCREEN-VALUE = SELF:ENTRY(ix + 1).
END.
ON CURSOR-UP OF rep DO: /* Change the SCREEN-VALUE of the combo box to the prev value from the drop‑down list. */
ix = SELF:LOOKUP(SELF:SCREEN-VALUE).
IF ix > 1 THEN
SELF:SCREEN-VALUE = SELF:ENTRY(ix - 1).
END.
temp-string = "".
FOR EACH Salesrep NO-LOCK:
temp-string = IF temp-string = "" THEN SalesRep.SalesRep ELSE temp-string + "," + SalesRep.SalesRep.
END.
ASSIGN rep:LIST-ITEMS IN FRAME main-frame = temp-string.
ENABLE rep WITH FRAME main-frame.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.