Was this helpful?
ChoiceList Class
The ChoiceList class provides attributes and methods for the field types that display a fixed set of choices to the end user, including EnumField (RadioField, OptionField, and ListField), MenuList, and PaletteField. One ChoiceList attribute, ChoiceItems, contains the set of choice values. ChoiceItems is an array of ChoiceItem objects.
In most applications, you specify the choice values on the property sheet for the field or menu. However, you also can manipulate the choices from the 4GL code. For example, you can use a select loop to load the values into the ChoiceItems array dynamically from values in the database. For an example, see the discussion of dynamic programming in the Programming Guide.
If you update a choice list that is attached to a displayed field, use the UpdChoiceList method on the field to make the changes visible.
For example, if you add items to an existing ChoiceList:
field(fg_color).ValueList.AddItem(enumvalue=CC_RED, textvalue='red', displayvalue='Red');
field(fg_color).ValueList.AddItem(enumvalue=CC_GREEN, textvalue='green', displayvalue='Green');
field(fg_color).ValueList.AddItem(enumvalue=CC_BLUE, textvalue='blue', displayvalue='Blue');
field(fg_color).UpdChoiceList();
If two or more fields on a form have the same choices, those fields can share one choice list. To implement this behavior, define the choices for one field and then assign the reference to that field’s choice list to the other fields.
For example, if fields fg_color and bg_color are both option fields that have the same set of choices, you may define the choices in the property sheet for the fg_color field only. Then, use the following statement in the frame’s initialize section so that bg_color can share the same list:
field(bg_color).ValueList = field(fg_color).ValueList;
Inherits From
Inherited By
None
Attributes
ChoiceItems
Methods
AddBitmapItem
AddItem
AddTextItem
BitmapByDisplay
BitmapByIndex
BitmapByText
BitmapByValue
DisplayByBitmap
DisplayByIndex
DisplayByText
DisplayByValue
IndexByBitmap
IndexByDisplay
IndexByText
IndexByValue
TextByBitmap
TextByDisplay
TextByIndex
TextByValue
ValueByBitmap
ValueByDisplay
ValueByIndex
ValueByText
Last modified date: 12/20/2023