ComboBox Class
A data entry control that is similar to the PopupMenu, but allows for either selection from a list or keyboard entry. It behaves like a single-line EditField that has a popup menu attached to it.
More information available in parent classes: PopupMenu:RectControl:Control:Object
The ComboBox can get the focus on all platforms.
Because this is a RectControl, see the RectControl for other properties and events that are common to all RectControl objects.
Examples
This code in the Open event handler populates a ComboBox and sets the initial value to the current month:
Dim i,last as Integer
Dim d as New Date
s="January,February,March,April,May,June,July," _
+"August,September,October,November,December"
last= CountFields(s,",")
For i=1 to last
me.addRow NthField(s,",",i)
Next
me.ListIndex=d.Month-1
The value of the ListIndex property contains the index of the selected item, but it does not indicate whether the user has entered text into the ComboBox. Examine the Text property to get the current menu selection or the text entered by the user. For example, the following line in the TextChanged event handler displays either the currently selected menu item or the text typed into the ComboBox.
This example adds an item to a ComboBox in its Open event handler
.
This example populates the RowTag identifier with a sequence number
:
Since RowTag is a Variant, you must first convert it to an Integer if you want to compare it to another integer. Do this with a simple assignment statement such as:
Then compare RecID to another Integer.
This example opens a new window when an item is chosen.
Dim w As ListEditorWindow
If ComboBox1.text="Edit List..." Then
w= New ListEditorWindow
End If
The following line changes the selected item in a ComboBox
:
Displaying the RowTag of the selected menu item:
See Also
ContextualMenu, EditField, PopupMenu controls; RectControl cla