ComboBox.Insert
The ComboBox Control Object that is returned by the AddComboBox function has its own functions which include the Insert function. The Insert function adds a selectable option to a specific position in the Combo Box's list.
Syntax |
ControlObject.Insert(Index Number, Text) 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 |
Adds a selectable option to the Combo Box. The option is added at the position defined by the Index Number. |
Arguments |
Index Number {integer} A number that corresponds to the position of the option in the Combo Box list. 0 is at the top of the list and the other numbers follow in sequence, so that the highest number is at the bottom of the list.
Text {string} The text that is shown for the option in the Combo Box. |
Returns |
Integer and String. |
Example:
The following script is used to add a Combo Box to a Form:
- Public Function ComboBoxForm
- Dim frmComboBox
- Dim pstrings (5)
- pstrings(0) = "None"
- pstrings(1) = "All Areas"
- pstrings(2) = "Area 1"
- pstrings(3) = "Area 2"
- pstrings(4) = "Area 3"
- pstrings(5) = "Area 4"
- Form.Init "Verify Control Action"
- Form.AddGroupBox 0,0,100,8,""
- Set frmComboBox = Form.AddComboBox (15,25, pstrings)
- frmComboBox.Insert 1, "Main Area"
- frmComboBox.Insert 2,"Central Building"
- Form.AddGroupBox 0,0,100,8,""
- Form.Show
- End Function
The pstrings variable defines the default options for the Check Box. The numbers for the options define their position in the Combo Box list, with 0 being at the top of the list and the highest number (in this case, 5) at the bottom of the list.
The AddComboBox function is used to add the Combo Box to the Form. It is positioned at coordinates 15, 25 on the Form and references the pstrings variable for its list entries.
The Insert function is used to add 2 more options to the Combo Box list. The first option is named "Main Area" and has an index number of 1. This means it is placed below the existing list option that has index number 0, but above the other list entries.
The second option is named "Central Building" and has an index number of 2. This means it is placed below the entries with index numbers 0 and 1, but above the other entries.