Kbase 21888: How To Clear (Display Blank in) a Combo-box
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  14/03/2002 |
|
SUMMARY:
This Knowledge Base applies to Progress Versions 8 and higher.
It shows you how to display a blank in a native drop-down-list combo-box defined as list-items (or list-item-pairs in V9).
Keep in mind that a combo-box that provides blank as a valid choice can be taken as 'violating the MS-Windows standard'.
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.
SOLUTION:
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).
NOTE: Once a combo-box is cleared in this way, its SCREEN-VALUE becomes ? (the unknown value).
References to Written Documentation:
Progress Knowledge Base Solution 16323, "How To Display Blank in a COMBO-BOX Using a SmartViewer"