JavaScript Editor js editor     Web development 

Main Page

The default behavior of a list allows one item at a time to be selected. You can, however, make it possible for a user to select multiple items in a list.

To allow multiple selected items in a list

  • Set the MultiSelect property of the list to true (.T.).

To process the selected items — to copy them to an array or incorporate them elsewhere in your application — loop through the list items and process those for which the Selected Property is true (.T.). The following code could be included in the InteractiveChange Event of a list box to display the selected items in a combo box, cboSelected, and the number of selected items in a text box, txtNoSelected:

В Copy Code
nNumberSelected = 0  && a variable to track the number
THISFORM.cboSelected.Clear && clear the combo box
FOR nCnt = 1 TO THIS.ListCount
   IF THIS.Selected(nCnt)
      nNumberSelected = nNumberSelected + 1
      THISFORM.cboSelected.Additem (THIS.List(nCnt))
THISFORM.txtNoSelected.Value = nNumberSelected

See Also

JavaScript Editor js editor     Web development