Wow, thank you so much. And it even removes multiple items!
ListBox only accepts "pipe-delimited list of entries", so using an array doesn't work.
Is there a way to make ListBox accept lists so I could use array commands such as adding items through Array.Push.?
Or is it better to continue operating on the list as a string (as done by trimming?)
Last question: How do I go about adding an item to the ListBox?
Code: Select all
list = blue|red|one|two
b = |
Gui, Font, s10
Gui, Add, ListBox, w230 r4 Multi vremove , %list% ;Multi allows multiple items to be selected
Gui, Add, Button , wp Default , Remove
Gui, Add, Edit, wp vname ,
Gui, Add, Button , wp , Add
Gui, Show, , Items
Return
ButtonRemove:
Gui, Submit, NoHide ;upon clicking remove
GuiControl,, remove, % b list := Trim(StrReplace(b list b, b remove b, b), b) ;StrReplace -> goes through list, |remove| is found and replaced with |. Trim -> new list has | removed (so empty item doesn't exist), there are |'s surrounding list to allow multiple items to be selected and deleted
Return
ButtonAdd:
Gui, Submit, Nohide
GuiControl,, add, % list := list + b name b
Return