Progress
AppBuilder
Developer’s Guide


Operating a Basic Combo Box

The Basic Combo Box widget consists of a joined fill-in and selection list. You can manipulate the contents of the list under program control.

Clearing the List Buffer

The list of items is stored as a string, pointed at by the LIST-ITEMS attribute. You can clear the list by assigning the empty string:

comboExample:LIST-ITEMS = "" . 

Setting LIST-ITEMS to the empty string clears the buffer immediately.

CAUTION: The Combo Box widget is created with a single item in its list. You should always clear that item as part of your initialization process.

You can also use a loop to delete the line items one by one:

DO WHILE comboExample:DELETE ( 1 ): /* empty statement */ END. 

In the example code, the DELETE method is called in a WHILE loop to repeatedly delete line item 1. When the buffer is empty of lines, DELETE will return FALSE and the WHILE loop will terminate.

Adding a Line Item

Using the INSERT() method, you can add a line item at any offset in the list, regardless of the Sort option.

The ADD-FIRST() and ADD-LAST() methods have a different result depending on whether the Sort option is set. If the option is not set, new items will be added to the top or bottom of the list, depending on which method you call. If the Sort option is set, new items will be inserted in sorted order regardless of which method you call.

The INSERT(), ADD-FIRST() and ADD-LAST() methods all return TRUE if they succeed, FALSE if they cannot perform the insertion.

If you are using simple line items—not item/value pairs—you can add more than one in a single call by combining them into a comma-separated list: "Item 1, Item 2, . . .,Item n".

If you are adding item/value pairs, you can only add one line per call.

Adding a User-supplied Line Item

Although a Combo Box appears to be a combined Fill-in and List, you cannot capture user input as new items. The Fill-in’s function is only to provide a way to select a list item other than by scrolling to find it.

To allow the user to add items to the list, use a separate Fill-in to capture the text for the new item or item/value pair and call the appropriate insertion method to add it:

This code, if used as the CHOOSE trigger for the pbAppend pushbutton, will move non-empty strings from the Fill-in to the list in the Combo Box:

IF fiNewItem:SCREEN-VALUE <> "" THEN DO: /* ignore event if field empty */ 
   ASSIGN fiNewItem.                     /* set the value of the Fill-in*/ 
   cbList:ADD-LAST( fiNewItem ).         /* append the new value to list */ 
   fiNewItem:SCREEN-VALUE = "".          /* clear Fill-in’s image... */ 
   fiNewItem = "" .                      /* ...and its value */ 
END. 

Deleting a Line from the List

Deleting a line requires only that you know the line number. This code will delete line 5 if it exists:

comboExample:DELETE ( 5 ). 

Finding a Line or Item in the List

Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095