Consultor Eletrônico



Kbase P105888: How to make a recent added item to a Combo-Box to be immediately displayed in the combo-box 
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   30/06/2005
Status: Unverified

GOAL:

How to make a recent added item to a Combo-Box to be immediately displayed in the combo-box

FIX:

The following code demonstrates the use of the LOOKUP() and ENTRY() methods to accomplish this.

Suppose that you have a named COMBO-BOX-1. Add the following code to any trigger (such as a into a choose trigger of a button).

DEFINE VARIABLE idx AS INTEGER NO-UNDO.

/* ADD-LAST() is simply adding a new item to the list-item,
you can choose any other method such as INSERT(), ADD-FIRST() and even REPLACE() as you wish */
COMBO-BOX-1:ADD-LAST("new item", "1").

/* LOOKUP() will returns the index of the specified item in the combo-box list */
idx = COMBO-BOX-1:LOOKUP("1").

/* ENTRY() Returns the character-string value of the specified list entry.

By assigning the SCREEN-VALUE to it will make the recent added item to the Combo-Box to be immediately displayed */
COMBO-BOX-1:SCREEN-VALUE = ENTRY((idx * 2), combo-box-1:LIST-ITEM-PAIRS).

NOTE: This code users a COMBO-BOX defined with LIST-ITEM-PAIRS. To use only a LIST-ITEMS replace use the followinng code instead.

DEFINE VARIABLE idx2 AS INTEGER NO-UNDO.
COMBO-BOX-2:ADD-LAST("new item").
idx2 = COMBO-BOX-2:LOOKUP("new item").
COMBO-BOX-2:SCREEN-VALUE = ENTRY(idx2, combo-box-2:LIST-ITEMS).