Creating enumerated types

Enumerated types, as discussed in the previous chapter, provide the user with a set of fixed options that we can code directly against. We understand at design time what they mean, as opposed to user-defined lists, which could represent anything.

Referenced as base enums in the AOT, they can be used directly on a table or referenced by an EDT, which, in turn, is added to the table. The reason for this is so that we can abstract and reuse a generic option list.

For example, the NoYes base enum has no label, but it offers the No and Yes options (No is first as it will be the default option). From this, we might create an EDT called ConAreYouSure, which has the Are you sure label. We can then use this label to create fields or dialog controls, and the interface can automatically use the Are you sure label and show the No and Yes options. This means we have one base enum that is reused in several places. This is ideal for general-purpose usage. We create new elements under the appropriate node in our project; the steps used to create a base enum are as follows:

  1. In your project, right-click on the Base enums node and navigate to New | Base enum.
  2. Rename it as required and open its property sheet.
  3. Set the Label property and create a new label.
  4. Use the Style property to control which type of user control AX will be created when added to a form by dragging and dropping; the default of Combo box is usually fine.
  5. Change UseEnumValue to Yes; this tells AX to use the EnumValue property of each element, allowing us to manually specify the value that AX stores in the database.
  6. We then add the elements by selecting New element from the context / right-click menu.
  7. For each required element, rename it as required and set the Label property. Of course, don't forget to create a label.

    Note

    Name is the symbol we reference in the code, Label is what is displayed on the UI, and EnumValue is the value written to the database.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.240.252