PB Docs: ListViewGadget multiselect demo prog
Posted: Thu Dec 31, 2015 6:48 am
After seeing one newbie question how to use the multiselect feature of a ListViewGadget i would like to suggest that the following example be included in the docs somewhere to demonstrate as after a quick search I could not find an example.
The program displays two list views. The left hand side being multiselect. After selecting some items clicking the button copies the selected items to the right hand side listView.
Code: Select all
Global Window_0
Global lstSelection, lstDisplay, btnCopy
Window_0 = OpenWindow(#PB_Any, x, y, 390, 280, "List View Multiselect", #PB_Window_SystemMenu)
lstSelection = ListViewGadget(#PB_Any, 20, 10, 140, 240, #PB_ListView_MultiSelect)
lstDisplay = ListViewGadget(#PB_Any, 230, 10, 140, 240)
btnCopy = ButtonGadget(#PB_Any, 170, 70, 50, 20, "Copy")
;Add Items to lstSelection
For i = 1 To 10
AddGadgetItem(lstSelection,-1,"Item " + Str(i))
Next i
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case btnCopy
;Clear display list
ClearGadgetItems(lstDisplay)
;Copy selected items to display list
For i = 0 To 9
If GetGadgetItemState(lstSelection,i) = 1
AddGadgetItem(lstDisplay,-1,GetGadgetItemText(lstSelection,i))
EndIf
Next i
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow