Language Reference Guide : System Classes : ChoiceField Class
 
Share this page          
ChoiceField Class
Note:  The ChoiceField class is used for classification only.
This class includes the fields that display a finite list of values from which the end user selects a single value. There are two subclasses: EnumField and PaletteField. These two subclasses differ primarily in that EnumField objects display choices to the user as text while PaletteField objects display choices as images. In both cases, the user can select only from among the listed values.
The valid choices are contained in the ValueList attribute. This attribute refers to a ChoiceList object that contains the valid set of values allowed for the field. Each value has text and an associated numeric value. When a value list is used in conjunction with a palette field, the list also contains a BitmapObject value.
ChoiceField variables can be of type varchar or integer. If you set the data type of the ChoiceField to a varchar variable, the value of the 4GL variable is the text of the current choice. If you set the data type to an integer variable, the value of the 4GL variable is the corresponding integer value of the current choice. In either case, EnumField objects display the choices as text and palette fields display the choices as images.
With one exception, both varchar and integer variables for choice fields can be nullable. (You can set this value with the IsNullable attribute in the Property Inspector.) If the variable is not nullable, one of the valid settings for the field is always selected. If it is nullable, then the field can be unselected by the user clicking on the currently selected value or by assigning null to the variable in the 4GL code. The exception to this behavior is option fields, which must always have a value selected.
You can dynamically set the choices displayed to the user. For information about this process, see the ChoiceList Class and ChoiceItem Class. For an example of this process, see the discussion of dynamic programming in the Programming Guide.
Inherits From
Object Class
FieldObject Class
FormField Class
ActiveField Class
ScalarField Class
Inherited By
EnumField
ListField
ListviewField
OptionField
PaletteField
RadioField
Attributes
CurEnumDisplay
CurEnumIndex
CurEnumText
CurEnumValue
ValueList
Methods
UpdChoiceList