mariaProgress
New Member
hello,
how can I fill a combo-box from database.
thanks.
how can I fill a combo-box from database.
thanks.
[FONT=courier new]DEFINE VARIABLE cListItems AS CHARACTER NO-UNDO.
DEFINE VARIABLE cName AS CHARACTER LABEL "Custome Name"
VIEW-AS COMBO-BOX
SIZE 30 BY 20
SORT
DROP-DOWN-LIST
AUTO-COMPLETION
NO-UNDO.
FORM cName WITH FRAME FrMyFrame SIDE-LABELS.
cListItems = "".
FOR EACH Customer NO-LOCK:
IF cListItems = "" THEN cListItems = Customer.NAME.
ELSE cListItems = cListItems + "," + Customer.NAME.
END.
ASSIGN cName:LIST-ITEMS IN FRAME FrMyFrame = cListItems.
ENABLE cName WITH FRAME FrMyFrame.
WAIT-FOR "CLOSE" OF THIS-PROCEDURE.[/FONT]
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.