Consultor Eletrônico



Kbase P110148: How to clear a combo-box widget?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/25/2005
Status: Unverified

GOAL:

How to clear a combo-box widget?

GOAL:

How to display a blank in a native drop-down-list combo-box defined as list-items or list-item-pairs?

GOAL:

How to reset what is currently being displayed in the box of a drop-down-list back to blank value?

FACT(s) (Environment):

Progress 8.x
Progress 9.x
OpenEdge 10.x

FIX:

The following code demonstrates how to display a blank in a native drop-down-list combo-box defined as list-items (or list-item-pairs in Progress 9.x or later). Developers might want to be able to clear a combo-box without including a blank item in the drop-down-list. This would appear to be possible since running a window containing combo-boxes with no initial values, renders them blank. Some developers have used the method:

MyCombo:LIST-ITEMS = MyCombo:LIST-ITEMS.

which does clear the combo-box but is slow. When there are many items in the list, this method consumes close to 100% CPU for a some time; an approach particularly unsatisfactory from a performance standpoint.

A better method is to apply the following:

MyCombo:ADD-FIRST(" "). /*ADD-FIRST(" "," ") for list-item-pairs*/
MyCombo:SCREEN-VALUE = " ".
MyCombo:DELETE(1).

Or you may even define your own method with the following UDF for reusability:

FUNCTION ClearCombo RETURNS CHARACTER ( h AS HANDLE ) :
h:ADD-FIRST(" "). /*ADD-FIRST(" "," ") for list-item-pairs*/
h:SCREEN-VALUE = " ".
h:DELETE(1).
END FUNCTION.

ClearCombo(MyCombo:HANDLE).