ComboBox, ListBox
These two controls let a user choose one item from a specified, generally scrollable, list. In addition, combo boxes can be configured to let the user enter a new item as well (hence the name combo—it's a combination of a text box and a drop-down). List boxes, not to be outdone, optionally support multiple selection. Both controls have far more in common than different, though.These are incredibly versatile, powerful controls. Some days, we might even argue that combos and lists are more powerful than grids.
Property |
Value |
Purpose |
Logical |
Determines whether a numeric Value indicates the row to highlight or the numeric data to highlight. |
|
Numeric |
The number of columns displayed in a list or in the drop-down portion of a combo. |
|
Logical |
Determines whether the lines between columns are visible. |
|
Character |
A comma-delimited list of the widths for the columns. Required with proportional fonts to make straight columns. |
|
Numeric |
The colors used to represent disabled items in the list or combo. |
|
Numeric |
Combo only. Determines how many items are displayed when you drop the combo open. |
|
Character or Numeric |
Determines which item in a combo is displayed when the combo is closed (and displays first on the list when it opens). Contains text typed by the user in a drop-down combo. For lists, indicates which item is highlighted. |
|
Numeric |
Determine which column of an array is displayed (one-column list or combo only) and which rows of the array are included. |
|
Logical |
Determines whether the list or combo uses FoxPro's smart incremental search technique or Windows (3.1's) dumb one. |
|
Numeric |
The colors used for the items in the list or combo. For a combo, affects only the drop-down portion. |
|
Array containing numeric |
Can contain numeric data matched to the items in a list or combo. |
|
Array containing character |
Contain the actual data from the list or combo. |
|
Numeric |
The number of items in the list or combo. |
|
Numeric |
The position of the currently selected item in the list or combo. |
|
Logical |
List only. Determines whether the list has mover buttons that let the user reorganize the items. |
|
Logical |
List only. Determines whether multiple items can be selected at the same time. |
|
Numeric |
The position of the most recently added item in the list or combo. |
|
Array containing file names |
Indicates, for each item, the icon to display next to it. |
|
Character |
The data in the list or combo, or a pointer to it. RowSourceType determines the actual meaning. |
|
Numeric |
The form of the data. Determines the interpretation of RowSource. |
|
Array containing logical |
Indicates, for each item, whether it's currently highlighted. |
|
Numeric |
The colors used for highlighted items. |
|
Numeric |
Combo only. The length and starting position of highlighted text in the text box portion of the combo. |
|
Character |
Combo only. The highlighted text in the text box portion of the combo. |
|
Logical |
Determines whether the items in the list or combo are sorted alphabetically. |
|
Numeric |
Determines the appearance of the control. |
|
Numeric |
Combo only. Specifies either combo box or drop-down list box. |
|
Numeric |
The position of the first item displayed in the list or combo. |
Event |
Purpose |
Supposed to fire when user clicks the down arrow on the scrollbar. Doesn't fire for lists, only for combos. |
|
Fires after user clicks down arrow to open combo, but before combo opens. (In early versions, fired late.) |
|
Fires each time the user moves in the list. Also fires for each character the user types. |
|
Fires when the mouse moves into the area occupied by the control. |
|
Fires when the mouse leaves the area occupied by the control. |
|
Fires when DisplayValue or Value is changed via code. |
|
Supposed to fire when user clicks the up arrow on the scrollbar. Doesn't fire for lists, only for combos. |
|
In a combo, fires whenever the user closes the combo (except with ESC) or, in a drop-down list, when the user types enough to choose a value. In a list, fires when the user leaves. |
|
In a combo, fires when focus is headed for the combo. In a list, fires whenever the list highlight moves. |
Method |
Purpose |
Add a new item to the list or combo. |
|
Remove all items from the list or combo. |
|
Convert between the two numbering schemes for items. |
|
Remove an item from the list or combo. |
|
Refresh the list or combo to include the latest data from the RowSource. |
The behavior of lists and combos with numeric data confuses people. The key point is that, even when we think we're seeing numbers in a combo or list, we're actually seeing characters. Combos and lists cannot show numeric data. If you specify a RowSource that's numeric, FoxPro internally converts the data to character before displaying it. |
Example |
* This code creates a subclass of ListBox * that is, by default, based on an array called aItems, * which is a property of the list itself. * The list is multi-select and displays * a message whenever an item is highlighted. DEFINE ArrayList AS ListBox DIMENSION aItems[1] RowSourceType = 5 RowSource = "This.aItems" MultiSelect = .T. PROCEDURE InteractiveChange WAIT WINDOW "Got one!" ENDPROC ENDDEFINE |