Delete multiple selection

Just starting out? Need help? Post your questions and find answers here.
User avatar
braveheart
User
User
Posts: 37
Joined: Mon Jan 04, 2010 5:54 pm

Delete multiple selection

Post by braveheart »

Code: Select all

#win=0
#lg = 1
OpenWindow(#win,0,0,300,400,"TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ListViewGadget(#lg,0,0,300,400, #PB_ListView_MultiSelect)
AddKeyboardShortcut(#win,#PB_Shortcut_Delete,#lg)
For i=0 To 10
  AddGadgetItem(#lg,i,"Listview Gadget "+Str(i))
Next
Procedure lselect()
  il = CountGadgetItems(#lg)-1  
  Dim al(il)
  in = 0  
  For i = 0 To il
    If GetGadgetItemState(#lg,i)      
      al(in) = i
      in+1
      SetGadgetItemState(#lg,i,0)
      ;RemoveGadgetItem(#lg,i) ;can't do this
    Else
      SetGadgetItemState(#lg,i,1)
    EndIf    
  Next
  ReDim al(in-1)  
  For i = 0 To in-1
    ;RemoveGadgetItem(#lg,al(i)) ;this one also
  Next   
EndProcedure
Repeat
  event=WaitWindowEvent()
  Select event
    Case #PB_Event_Menu
      Select EventMenu()
        Case #lg
          lselect()
      EndSelect   
  EndSelect  
Until event=#PB_Event_CloseWindow
How to delete multiple selection on listviewgadget?
infratec
Always Here
Always Here
Posts: 7583
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Delete multiple selection

Post by infratec »

Hi,

where is the problem ?

This works for me

Code: Select all

Procedure lselect()
  il = CountGadgetItems(#lg) - 1 
  For i = 0 To il
    If GetGadgetItemState(#lg,i)     
      RemoveGadgetItem(#lg,i) ;can't do this
    EndIf   
  Next
EndProcedure
Best regards,

Bernd
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Delete multiple selection

Post by c4s »

I don't know if it's the problem here but I think you have to go through the list from bottom to top.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Post Reply