Using DropDownListBox controls

Drop-down lists are another way to present simple lists of information to the user. You add DropDownListBox controls to windows in the same way you add other controls: select DropDownListBox from the Insert>Control menu and click the window.

Adding items to drop-down list controls

In the painter Use the Items property page for the control to add items.

StepsTo add items to a DropDownListBox or DropDownPictureListBox:

  1. Select the Items tab in the Properties view for the control.

  2. Enter the name of the items for the ListBox.

In a script Use the AddItem and InsertItem functions to dynamically add items to a DropDownListBox at runtime.

AddItem adds items to the end of the list. However, if the list is sorted, the item will then be moved to its position in the sort order. Use InsertItem if you want to specify where in the list the item will be inserted.

Table 6-2: Using the InsertItem and AddItem functions

Function

You supply

InsertItem

  • Item name

  • Position in which the item will be inserted

AddItem

  • Item name

This example inserts three items into a DropDownListBox in the first, second, and third positions:

This.InsertItem ("Atropos", 1)
This.InsertItem ("Clotho", 2)
This.InsertItem ("Lachesis", 3)

NoteUsing the Sort property You can set the control’s sort property to true to ensure that the items in the list are always arranged in ascending sort order.