1C:Enterprise 8.3. Practical Developer’s Guide. Lesson 27 (2:10). Form development techniques. Selection list in a text box

Selection list in a text box

You can use selection lists in text boxes, which improves their usability.

A text box that has a reference type, such as Warehouse or Employee, by default includes a selection button that opens the selection form for a referenced object.

You might need to implement a similar selection from a set of predefined values for fields of other types.

Let us review a very simple example where a user needs to enter customer addresses starting with city names.

In Designer mode

Let us add a selection list to a text box.

  1. In Designer, open the configuration object editor of the Customers catalog.
  2. On the Data tab, add the Address attribute of the String type with length 25.
  3. Open the Customers catalog item form.
  4. Expand its main Object attribute and drag the Address field from the attributes pane to the form controls pane.
  5. In the property palette that is opened, set the ListChoiceMode check box.
  6. In the ChoiceList field, click the selection Lesson 27 (2:10). Form development techniques / Selection list in a text box / In Designer mode button and then use the Add Lesson 27 (2:10). Form development techniques / Selection list in a text box / In Designer mode button to add cities: New York, New Rochelle, and Boston (fig. 27.24).

    Lesson 27 (2:10). Form development techniques / Selection list in a text box / In Designer mode
    Fig. 27.24. Creating a selection list for a text box

In 1C:Enterprise mode

Let us test the text box.

  1. Start 1C:Enterprise in the debug mode and open the customer form.
  2. In the Address field, type n.

    The platform suggests two cities starting with this letter (fig. 27.25).

    Lesson 27 (2:10). Form development techniques / Selection list in a text box / In 1C:Enterprise mode
    Fig. 27.25. Selecting from a set of predefined values in a text box

    The operations that you performed in Designer are also available in 1C:Enterprise script. This means that you can use some algorithm for dynamic generation of a selection list for a text box.

    Moreover, you can use 1C:Enterprise script to modify an automatically generated selection list (for example, a selection list in an automatically generated form). To do so, use the ChoiceDataGetProcessing event handler that is located in the object manager module. For example, to implement picking a catalog item in a text box, you can put the event handler to the catalog manager module.

Leave a Reply

Your email address will not be published.

 

1C:Enterprise Developer's Community