EnumField Class
Note: The EnumField class is used for classification only.
This class includes the fields that display a finite list of values from which end users can select a single value. There are three subclasses—RadioField, ListField, and OptionField—that display and manipulate the choices available to the user in different ways. See the descriptions in this chapter for the individual subclasses for more detailed information about the implementation of each subclass.
The valid choices for the field are contained in the ValueList attribute of the ChoiceField class. 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 integer value.
You can map EnumField objects to variables of either varchar or integer data type. In either case, the user sees a list of the choices as text. If you map the field to a varchar variable, the value of the variable contains the text of the current choice.
For example, assume you have a radio field, color_field, whose variable is declared as varchar and that the field displays three choices: Red, Green, and Blue. In your 4GL code, all references to color_field (without using the field function) return the string Red, Green, or Blue, depending on which of the radio buttons is currently selected.
To set the radio button selection to Blue, set the value of color_field to the string Blue. This action highlights that button and turns off the previous selection.
Case sensitivity is maintained for the text values in enumerated fields that have varchar variables.
If you map the enumerated field to an integer variable, the value of the variable is the integer enumerated value associated with the text. Using the previous example for color_field, assume that Red is given an enumerated value of 101, Green a value of 102, and Blue a value of 103. To change the selection to the Blue button, set color_field to the value 103.
For all enumerated fields except option fields, both varchar and integer variables can be nullable. Use the IsNullable toggle on the field's property sheet. 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.
Note: Option fields cannot be nullable. They must always have a value selected.
You can dynamically set the choices displayed to the user. For an example of this process, see the dynamic programming example in the Programming Guide.
For more detailed information about the ValueList associated with enumerated fields, see the descriptions of the
ChoiceList Class, the
ChoiceItem Class, and the
ChoiceField Class.
Inherits From
Inherited By
ListField
ListViewField
OptionField
RadioField
Attributes
ExactWidth
IsBold
IsItalic
IsPlain
IsUnderlined
MinimumWidth
TypeFace
TypeFaceName
TypeSize
Methods
None