ComboBox.Sort
The ComboBox Control Object that is returned by the AddComboBox function has a Sort property. The Sort property allows the script to place the Combo Box list options in alphabetical order instead of the default Add or Insert orders.
When you use the ComboBox.Add function, the list option that you add is added to the bottom of the list. This means that the order of the list is defined by the order in which you add options to the list. If you use the ComboBox.Insert function, the list option you create is added to a specific place in the list and so you define the list order by specifying the positions of the options. With the ComboBox.Sort property, you can set a combo box to ignore the Add and Insert orders and apply sorting by alphabetical order of the list option names.
Syntax |
ControlObject.Sort = Value Where ControlObject. is the name of the variable (declared in your script) that is used to store the Combo Box Control Object that is returned by the AddComboBox function. |
Description |
Re-orders the Check Box options into alphabetical order. |
Arguments |
Value {Boolean} If set to True (1), the Combo Box options are ordered alphabetically; if set to False (0), the Combo Box options are ordered according to when they were added (if the ComboBox.Add function was used) or in a user-defined order (if the ComboBox.Insert function was used). |
Returns |
Boolean |
Example:
A script adds a Combo Box to a Form. The script does not make use of the Combo Box's Sort property, and so the Combo Box's 3 options are ordered according to the order in which they were created:
- Display Alarms—This option is shown at the top of the list as it was the first option to be added.
- Acknowledge Alarm—This option is shown next on the list as it was added after the Display Alarms option but before the Hand Control Point option.
- Hand Control Point—This option is shown at the bottom of the list as is the latest list option to be added.
The script is altered so that the Combo Box list options are shown in alphabetical order:
ComboBox1.Sort = True
Where ComboBox1 is the variable that is used to store the ComboBox Control Object that is returned by the AddComboBox function, and True sets the Combo Box's options to be listed alphabetically.
When the Form is next displayed, the Combo Box options are displayed in alphabetical order:
- Acknowledge Alarm
- Display Alarms
- Hand Control Point.