PreviousNextIndex

COMBO-BOX phrase

Describes a combo-box widget. A combo-box represents a field or variable, and consists of a field value and an associated drop-down list of possible values.

Note: Does not apply to SpeedScript programming.
Syntax

COMBO-BOX 
  [ LIST-ITEMS item-list | LIST-ITEM-PAIRS item-pair-list ] 
  [ INNER-LINES lines ] [ size-phrase ] [ SORT ] 
  [ TOOLTIP tooltip ] 
  [ SIMPLE | DROP-DOWN | DROP-DOWN-LIST ] 
  [ MAX-CHARS characters ]  
  [ AUTO-COMPLETION [ UNIQUE-MATCH ] ] 

Use the following syntax to specify a combo-box widget for displaying values in a browse column:

Syntax
COMBO-BOX 
  [ LIST-ITEMS item-list | LIST-ITEM-PAIRS item-pair-list ] 
  [ INNER-LINES lines ] [ SORT ] 
  [ DROP-DOWN | DROP-DOWN-LIST ] 
  [ MAX-CHARS characters ]  
  [ AUTO-COMPLETION [ UNIQUE-MATCH ] ] 

LIST-ITEMS item-list
LIST-ITEM-PAIRS item-pair-list
label
value
INNER-LINES lines
size-phrase
SORT
TOOLTIP tooltip
SIMPLE
DROP-DOWN
DROP-DOWN-LIST
MAX-CHARS characters
AUTO-COMPLETION
UNIQUE-MATCH
Examples

The first example, r-combo.p, views a date field as a combo-box. When you run this procedure, you can choose a date value from the drop-down list. When you choose a new value, the VALUE-CHANGED trigger updates the value of out-string to an event associated with the new date value. The example initializes the drop-down list by building a comma-separated list of values and then assigning the string to the LIST-ITEMS attribute of the combo-box.

r-combo.p
DEFINE VARIABLE hist-date  AS DATE      NO-UNDO FORMAT "99/99/9999" 
  VIEW-AS COMBO-BOX LIST-ITEMS 07/04/1776, 07/11/1969, 09/10/1993. 
DEFINE VARIABLE hist-event AS CHARACTER NO-UNDO INITIAL 
  "Declaration of Independence,Man walks on moon,Progress Version 7 ships". 
DEFINE VARIABLE out-string AS CHARACTER NO-UNDO FORMAT "x(36)". 
DEFINE FRAME main-frame 
  hist-date out-string 
  WITH NO-LABELS TITLE "Historic Events". 
ON VALUE-CHANGED OF hist-date DO: 
  out-string = ENTRY(SELF:LOOKUP(SELF:SCREEN-VALUE), hist-event). 
  DISPLAY out-string WITH FRAME main-frame. 
END. 
ENABLE hist-date WITH FRAME main-frame. 
APPLY "VALUE-CHANGED" TO hist-date IN FRAME main-frame. 
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW. 

The following example, r-combo2.p, builds a combo-box based on field values from a database. It defines triggers that allow you to change the value of the combo-box without displaying the drop-down list. They allow you to scroll through the values using the CURSOR-DOWN and CURSOR-UP keys or to jump to a specific value by typing its first letter.

r-combo2.p
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. 

Notes
See also

Format phrase, SIZE phrase, VIEW-AS phrase


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex