Home About us Development Training Support |
FoxPro multiselect listboxThe standard FoxPro listbox control allows the user to easily select an item from the list that is displayed. If you set the property of the listbox then you can let the user make multiple selections from the list. These selections follow the usual conventions of the Windows user interface:
Coding for multiple selectionsThe first step is to set the MultiSelect property of the listbox to .T.. This enables the behaviour described above. When a row is selected a value of .T. is stored in the equivalent entry in the control's Selected property. This property is an array with one element for every row in the listbox. Scan this array to determine which rows have been selected. In the example above, the InteractiveChange event of the listbox calls the following code to create the list of selected items:
With Thisform
.edtSelected.Value = "" For ln = 1 To .lstMulti.ListCount If .lstMulti.Selected(ln) *-- Add this to the editbox .edtSelected.Value = .edtSelected.Value + ; .lstMulti.List(ln) + Chr(13) Endif Next ln EndWith Similar loops behind the and buttons set all elements of the array to .T. and .F. respectively.Other listbox propertiesBy default the selected items will appear in the standard colours from the user's Windows colour scheme. You can override these with the and properties but remember that the user may have taken great care in chosing their own colour scheme to suit their own requirements. To take an extreme example, a user with some form of red/green colour blindness would not be pleased if you ignored their own preferences and displayed selected items in red and green.AlternativesThe listbox with its property is an easy way of letting your user make multiple selections. Consider using a grid with checkboxes if you need a more sophisticated interface:
|
Hints & tips
The textbox class in Visual FoxPro 9 has a new Autocomplete
property which shows the user the previous values that have
been entered in that textbox.
More...
|