Providing the user with a fixed set of options to choose from in a field is a recurring task in application programming. For example, in a field where the user frequently has to enter the title of a contact, providing a list of titles helps the user. You can only enter options that have been defined in the Properties window of the field or variable. The first option is displayed in the text box. If the OptionString property has a blank as the first option, the text box is blank. In the OptionString property of the control, you can select a subset of the options already defined for the field, but you cannot add options.

In the following procedures, the first procedure explains how to create a card type form that you need to create the drop-down list. The second procedure explains how to create the drop-down list of options.

To create a card type form

  1. Open Object Designer, click Form, and click then New to open the New Form window.

  2. Create a Card-Type Form based on the Contact table and click OK.

  3. In the Card-Type Form Wizard, click the No, I want a plain form option, and then click Next.

  4. Add the following fields to the form: No., Name, Address, Phone No., and Company No.

  5. Click Finish and in Form Designer, expand the form and the container control.

  6. Add a new text box and a label.

To create a drop-down list of options

  1. Select the text box that you just created and open the Properties window.

  2. In the Caption field, enter Organizational Level. The field or variable that is the SourceExpr of the control must be of the Option data type, and the options must be entered as the OptionString property of the field or variable. In this example you will use a variable.

  3. Click View, and then click C/AL Globals to open the C/AL Globals window.

  4. Create a variable called Organizational Level of data type Option and open the Properties window for this variable.

  5. In the Value field OptionString property, enter the following list: Chief Executive Officer,Chief Financial Officer, Junior Manager,Manager,Salaried Employee,Senior Manager. These are the values that are currently available in the Organizational Levels table.

  6. Open the Properties window of the text box and bind it to the variable. To do this, click the AssistButton in the Value field of the SourceExpr property to open the C/AL Symbol Menu window.

  7. Ensure that the Paste Arguments option is active, select Organizational Level, and then click OK.

  8. Save and compile the form.

See Also