Setting Choices for List and Combo Boxes

Description

A data field displayed as a list box accepts only values that are in its choice list. A data field displayed as a combo box accepts both values in the list and new values entered by the user. These images show a list box in regular and combo box formats.

  1. Select the control, choose Object > Properties and display the Setup tab.

  2. Select "List Box" or "Combo Box" in the Field-Type list.

  3. Display the Choices tab.

  4. Select one of the Choices for control. The options are:

    • " User Defined "

    • " Computed Automatically "

    • " Populated using Xbasic "

  5.  User Defined Choices

    If you selected "User Defined" in step 4:

    • 1. Select the display style. The options are:

      • "Bitmap followed by text"

      • "Bitmap only"

      • "Bitmap over text"

      • "Text followed by bitmap"

      • "Text only"

      • "Text over bitmap"

    • 2. Enter choices one per line. Refer to Specifying User Defined Choices.

    • 3. Optionally, click or the 'ZA down' icon to sort the entries in ascending or descending order.

    • 4. If the selection in step 5a included bitmaps, click Define bitmaps... to display the Define Bitmaps dialog box. Otherwise, click OK to save your choices definition.

    • 5. In the Define Bitmaps dialog box select each entry in turn and click Define Bitmap to display the Define Picture dialog box.

    • 6. In the Define Picture dialog box optionally check Button displays a different picture when a button is pressed. This causes the Pressed tab to appear.

    • 7. Optionally, on the Default tab click Embedded and Select Embedded Bitmap. Navigate to the image, select it, and click Open.

    • 8. Optionally, on the Default tab click File and the 'up' button. Navigate to the image, select it, and click Open.

    • 9. Optionally, on the Default tab click Internal and the 'up' button. Select the image from the Insert Image dialog box, and click Insert.

    • 10. If the Pressed tab is visible, display it, and select another image in the same manner as Described by steps 5h through 5j.

    • 11. Click OK, OK and OK to save your choices definition.

    • 12.

  6.  Choices Automatically Computed

    If you selected "Computed Automatically" in step 4 Select a data Source. The options are: :

    • " Values from a Table/Set "

    • " Field List "

    • " Expression (that returns a CR-LF delimited list) "

    • "Browse Layouts"

    • "Form Layouts"

    • "Report Layouts"

    • "Label Layouts"

    • "Letter Layouts"

    • "Append Operations"

    • "Copy Operations"

    • "Export Operations"

    • "Import Operations"

    • "Join Operations"

    • "Mark Operations"

    • "Post Operations"

    • "Query Operations"

    • "Summary Operations"

    • "Update Operations"

    • "Xtab Operations"

    • "Tables"

    • "Sets"

    • "Menu Objects"

    • "Toolbar Objects"

    • "Scripts"

    • "Functions"

    • "Bitmaps"

  7.  Values from a Table/Set

    If you selected "Values from a Table/Set" in step 6a:

    • 1. Select a table or set in the From Table list.

    • 2. Do one of the following:

      • Select a field to display in the Field/expression field.

      • Select "" in the Field/expression field to display the Expression Builder. Enter an expression that defines values to display and click OK.

  8. This expression may return more than one field as long as they are separated by "|" characters (e.g. Product_Name + "|" + Product_No ). Only the first field will display in the list box.

  9. Optionally, click the 'up down arrow' icon to display the Order Builder to order the list choices that will appear.

  10. A filter expression selects values from a lookup table based on one or more values in the current table. Optionally check Enable Filter Expression and click Edit Filter Expression to display the Filter Expression dialog box.

  11. Optionally, check Display only unique keys to avoid duplicate entries in the list.

  12. Optionally, click Preview to see the data that the list will contain.

  13. Click OK to save your choices.

  14.  Field List

    If you selected "Field List" in step 6a, select the table or set in the Display fields for which table? list.

  15.  CR-LF Delimited List

    If you selected "Expression (that returns a CR-LF delimited list)" in step 6a:

    • 1. In the Expression field enter an expression or function that returns a list of CR-LF delimited values. Optionally, click the 'xy' button to display the Expression Builder dialog box.

    • 2. Optionally, enter an expression in the Watch Expression field. When this value changes, Alpha Anywhere will refresh the choice list.

    • 3. Optionally, click Preview to see the data that the list will contain.

    • 4. Click OK to save your choices.

  16.  Lists of Layouts and Operations

    If you selected a list of layouts or operations in step 6a:

    • 1. Click OK to save your property settings.

    • 2. Right click on the form and select Events > OnInit.

    • 3. In the Create new Event Script dialog select Create using Xbasic and click OK.

    • 4. Enter Xbasic code structured as follows. Substitute your control's name for .

    • 5. Optionally, substitute your list of choices, one per line, for:

      ... 
      DIM pObj as P
      pObj = topparent:.this
      pObj.settings.dynamic_list = <<%str%
      ...
      %str%
    • Optionally, substitute a call to a function that returns a CR-LF delimited list for:

      <<%str% 
      ... 
      %str%
      DIM pObj as P
      pObj = topparent:.this
      pObj.settings.dynamic_list = MyFunction()

See Also