PB Docs: ListViewGadget multiselect demo prog

Everything else that doesn't fall into one of the other PB categories.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

PB Docs: ListViewGadget multiselect demo prog

Post by collectordave »

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.

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
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.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: PB Docs: ListViewGadget multiselect demo prog

Post by WilliamL »

Maybe this should be in 'Bugs-Documentation'?
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.31b2
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: PB Docs: ListViewGadget multiselect demo prog

Post by collectordave »

Not a bug.

There seems to be a few posts from this topic missing?
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: PB Docs: ListViewGadget multiselect demo prog

Post by WilliamL »

I agree that it is not a bug but I found, when I made a suggestion on the Docs thread, that it got a response from the people who wrote the Docs. :wink:
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.31b2
Post Reply