The Combo Box (

) form object represents a
combo box, which can either work as a combination of a
drop-down list box and an editable text field or as a drop-down list box without editing. The
Settings window contains the following sections:
In this section you define the data source for a combo box. The section contains a tree with a filtered view of the tree in the Application Builder window. The nodes either represent some sort of data or have children that do. For a combo box, you can use variables from the model or those defined under
Declarations, including
Unit Set nodes. You can extend the list of available data nodes by clicking the
Switch to Model Builder and Activate Model Data Access button (

) in the
Source section header, which takes you to the Model Builder, and then selecting a node in the
Model Builder branch whose data you want to access. With this button active, the
Settings window of the selected node displays a
Select Data Source check box (a green square) next to the settings that you can include. Click to select the check box to include that data as an available source node for combo boxes.
When you select a node that represents data, the Use as Source toolbar button (

) below the tree becomes enabled. You can also right-click the node and choose
Use as Source. You can also click the
Create button (

) in the
Source section header to create a new variable declaration and use it as the source. A
Create and Use Variable dialog box opens, so that you can select the data type of the source (if applicable), its name, and its initial value. The name cannot be in conflict with any existing variable declaration. Click the
Edit Node toolbar button (

) below the tree to move to the corresponding node. If necessary, the program switches to the Model Builder.
In the Initial value list, choose a method to define an initial value for the combo box. The options are
First allowed value,
From data source (the default; to use the value specified by the selected data source), and . For the
Custom value option, a
Value list shows the allowed values currently present for the form object and depends on the selected available choice lists and their values. If the data source is a setting from the embedded model that has a list of allowed values, those values are also included in the
Value list. If a selected initial value becomes invalid because it has been removed from the choice list, for instance, it is kept as initial value with the text
Invalid initial value followed by the value.
In the Selected list, add
Choice List nodes that contribute allowed values to the combo box. If the selected data source is a list with a set of allowed values, only a subset of those values can appear in the allowed values of the combo box. All other values in the selected choice lists are ignored. Available
Choice List nodes appear under
Available. Click the
Add Selected 
button to add the selected
Choice List node to the list under
Selected. Click the
Remove Selected 
button to remove a selected
Choice List node from the list under
Selected. You can also double-click a
Choice List node to move it from
Available to
Selected and the other way around. Click the
Add New Choice List button (

) to open a
Choice List window where you can define a new choice list. Add the allowed values in the
Value column and their corresponding names in the
Display name column. Click
OK to add the new choice list as a
Choice List node (

) under
Declarations and directly under
Selected in the list under
Choice List.
If you select a property that has a list of allowed values as the data source in the Source section, that property becomes a node initially placed in the
Selected list. You can move it to the
Available list, thereby clearing the list of allowed values. You can move it back again or add a custom choice list with values that also belong to the list of values for the property. If the property list and a choice list node are both in the
Selected list, they will be merged. Identical values pick the description from the first item in the list under
Selected, so in this way you can rename one of the items in the property list. If you decide to switch the source to another property in the embedded model that also has a list of allowed values, the previous property list node is removed from both the
Available and the
Selected lists, and the new node is added to the
Selected list.
Select the Allow other values check box to get a combo box where you can type arbitrary values. Such combo boxes can accept any value and are not restricted to the values defined by the choice lists.
•
|
From the Horizontal alignment list, choose Left, Center, Right, or Fill, which automatically expands the form object to fill the cell in the horizontal or vertical direction (where applicable).
|
•
|
From the Vertical alignment list, choose Middle, Top, Bottom, or Fill, which automatically expands the form object to fill the cell in the horizontal or vertical direction (where applicable).
|
The need to specify the alignment is most obvious when working in the grid mode, as it controls how the form object is aligned in its grid cell. Aligning the form object can be useful in the sketch mode too, and you can then use the alignment tools on the Arrange menu in the
Form toolbar’s
Sketch section. When running the application in any client other than the Windows client, the form objects may not be positioned exactly as seen in the Application Builder. This is because the form objects may have a different size in other clients, giving them a slightly different positioning. Specifying the alignment ensures that the form objects are aligned as you want them to be in all clients.
You can also specify the width of the combo box. Enter a width (in points) in the Width field. If you have chosen
Fill from the
Horizontal alignment list, you can instead specify a
Minimum width. Choose
Automatic to compute the minimum width automatically (typically this means a minimum size of 0), or choose
Manual to specify a minimum width in the text field underneath. The
Height field is unavailable because the height of the combo box is determined by the software.
Additionally, in the sketch mode, you can specify the form object’s absolute position using the Position x and
Position y fields. In the grid mode, you can position the object in the grid and see the grid position as the
Row,
Column,
Row span, and
Column span values.
Under Cell margin (in grid mode only), you can control the margins around the form object. By default, the margins are taken from the parent form. From the
Cell margin list, choose:
•
|
None, to use no margin around the form object.
|
•
|
Custom, to specify the margins for the form object in the Horizontal and Vertical text fields.
|
•
|
From the Text color list, select a color to use for the text: Inherit (the default; the form object then uses the setting from the Form it is located in), any of the predefined basic colors, or Custom, which makes it possible to select a custom color from a color palette that opens.
|
•
|
Select the Italic check box to use italics (an italic font).
|
Under State, you can control the initial state of the combo box when users run the application. By default, the combo box is visible and enabled. Clear the
Visible or
Enabled check box if you want to make the initial state so that the combo box is hidden or unavailable. You can then make it visible or enable it using a method.
You can add a code method that the application runs when the data in the combo box changes. The event is triggered after the new data value is stored in the data source. The On data change list contains
None (the default) and any available methods. To add a local method for this event, click the
Create Local Method button (

) or right-click the combo box object. The selected method in the
On data change list then changes to
Local method and an editor window for the local method opens, where you can define its contents. You can also click the
Go to Source button (

) to open an editor window for the selected method. Click the
Remove Local Method button (

) to delete the local method.
•
|
If the On data change list is set to a method, Ctrl+Alt-click opens that method’s editor window.
|
•
|
If the On data change list is set to None, Ctrl+Alt-click creates a local method if needed, sets the list to Local method, and opens the local method’s editor window.
|