' How to use a multiselected ListBox in Rapid-Q by William Yu
' All you really have to do is set MultiSelect to True, and then check
' the array of Selected items.

CONST False = 0
CONST True = NOT False

DECLARE SUB ButtonClick

CREATE Form AS QForm
  Height = 290
  Width = 350
  Caption = "Multi-Select ListBox"
  Center
  CREATE ListBox1 AS QListBox
    MultiSelect = True
    Width = 150
    Height = 200
    AddItems "Item 1", "Item 2", "Item 3", "Item 4", _
             "Item 5", "Item 6", "Item 7", "Item 8", "Item 9"
  END CREATE
  CREATE ListBox2 AS QListBox
    Left = 190
    Width = 150
    Height = 200
  END CREATE
  CREATE Button AS QCoolBtn
    Left = 155
    Top = 50
    Width = 30
    Caption = ">"
    OnClick = ButtonClick
  END CREATE
  CREATE Label AS QLabel
    Left = 10
    Top = 220
    Caption = "To multiselect individual items, " + _
              "just hold down the CTRL key" + CHR$(13) + _
              "while pressing the mouse button."
  END CREATE
  ShowModal
END CREATE


SUB ButtonClick
  ListBox2.Clear
  FOR I = 0 to ListBox1.ItemCount-1
    IF ListBox1.Selected(I) THEN          '' Add only the selected items
      ListBox2.AddItems ListBox1.Item(I)
    END IF
  NEXT
END SUB
