Listbox to Listbox item transfer? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
KBONeal
Posts: 2
Joined: 18 Aug 2017, 09:04

Listbox to Listbox item transfer?

18 Aug 2017, 10:20

I need to be able to double click an item in one Listbox and it transfer to an empty Listbox adjacent to; I am attempting to set up a system where you can pick items from List 1, the selected items populate into list, and eventually export to quote template in Excel.

Also.. If possible, I would like to figure out a way to have the original list numbered, but when transferred to the second list, unnumbered.

Any help on these matters would be greatly appreciated!
User avatar
Spawnova
Posts: 554
Joined: 08 Jul 2015, 00:12
Contact:

Re: Listbox to Listbox item transfer?  Topic is solved

18 Aug 2017, 10:57

I'm not sure what you meant by numbering so you may need to tweak it a little

Code: Select all

list1 := ["item1","item2","item3","item9999"]
list2 := []

Gui,Add,Listbox,x5 y5 w150 h250 vlb1 gaddItem, % arrayToString(list1,1)
Gui,Add,Listbox,x170 y5 w150 h250 vlb2, % arrayToString(list2)
Gui,Show,,Listbox Example
return

addItem:
gui,submit,nohide
list2.insert(RegExReplace(lb1,"^\d+\.\s","")) ;add list1 item to list2, replace the number if its present (^=beginning, \d+=numbers until not number,\.=literal dot,\s=space)
guicontrol,,lb2,| ;clear listbox
guicontrol,,lb2, % arrayToString(list2)
return

arrayToString(a,numbered=0) { ;convert array elements into listbox string
	s := ""
	loop % a.length() {
		s .= (a_index > 1 ? "|" : "") (numbered ? a_index ". " : "") a[a_index]
	}
	return s
}
KBONeal
Posts: 2
Joined: 18 Aug 2017, 09:04

Re: Listbox to Listbox item transfer?

18 Aug 2017, 12:59

Hey! Thanks a lot, this worked for the list to list transfer, so there is one big hurdle out of the way, I really appreciate it!

Edit: I forgot to mention that after a slight tweak, this also fixed the issue with the list numbering issue. Thanks again!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: OrangeCat and 134 guests