autoitash Posted April 25, 2011 Share Posted April 25, 2011 Hello, I am trying to delete items from a listbox after the item has been moved to another listbox. For eg: from Listbox1 when I move an item into Listbox2, I need to delete it in Listbox1. Can someone please help? Thanks! Here is my partial code. Func Selectapps() $Count = 0 GUICreate("List of apps to be selected") $ListofApps = GUICtrlCreateList("", 10, 10, 120, 320) While $Count < $appIdCount GUICtrlSetData($ListofApps, $AppIdProc[$Count][0], "") $Count = $Count + 1 WEnd $AppsAdded = GuiCtrlCreateList("", 200, 10, 120, 320) $moverightbtn1 = GuiCtrlCreateButton(">>",150,100,40,20) $moveleftbtn1 = GuiCtrlCreateButton("<<",150,130,40,0) GUISetState() $Count1 = 0 While 1 $button = GUIGetMsg() If $button = $GUI_EVENT_ClOSE Then ExitLoop EndIf If $button = $moverightbtn1 Then $rightmoveitem = GuiCtrlRead($ListofApps) ConsoleWrite($rightmoveitem & @CRLF) GuiCtrlSetdata($AppsAdded, $rightmoveitem) $Count1 = $Count + 1 EndIf If $button = $moveleftbtn1 Then $leftmoveitem = GuiCtrlRead($AppsAdded) ConsoleWrite($leftmoveitem & @CRLF) GuiCtrlSetdata($ListofApps, $leftmoveitem) $Count1 = $Count + 1 EndIf WEnd EndFunc Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 26, 2011 Share Posted April 26, 2011 Put [code][/code] tags around your code, please.This is one way: expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListBox.au3> Global $AppIdProc[5][2] = [["Audigy", ""],["Firefox", ""],["LibreOffice", ""],["Gimp", ""],["WINE", ""]], $appIdCount = 5 Selectapps() Func Selectapps() $Count = 0 GUICreate("List of apps to be selected") $ListofApps = GUICtrlCreateList("", 10, 10, 120, 320) While $Count < $appIdCount GUICtrlSetData($ListofApps, $AppIdProc[$Count][0], "") $Count = $Count + 1 WEnd $AppsAdded = GUICtrlCreateList("", 200, 10, 120, 320) $moverightbtn1 = GUICtrlCreateButton(">>", 150, 100, 40, 20) $moveleftbtn1 = GUICtrlCreateButton("<<", 150, 130, 40, 0) GUISetState() $Count1 = 0 While 1 $button = GUIGetMsg() If $button = $GUI_EVENT_ClOSE Then ExitLoop EndIf If $button = $moverightbtn1 Then $rightmoveitem = GUICtrlRead($ListofApps) If StringStripWS($rightmoveitem, 8) Then ConsoleWrite($rightmoveitem & @CRLF) GUICtrlSetData($AppsAdded, $rightmoveitem) $iSel = _GUICtrlListBox_GetCurSel($ListofApps) _GUICtrlListBox_DeleteString($ListofApps, $iSel) $Count1 = $Count + 1 EndIf EndIf If $button = $moveleftbtn1 Then $leftmoveitem = GUICtrlRead($AppsAdded) If StringStripWS($leftmoveitem, 8) Then ConsoleWrite($leftmoveitem & @CRLF) GUICtrlSetData($ListofApps, $leftmoveitem) $iSel = _GUICtrlListBox_GetCurSel($AppsAdded) _GUICtrlListBox_DeleteString($AppsAdded, $iSel) $Count1 = $Count + 1 EndIf EndIf WEnd EndFunc ;==>Selectapps Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
autoitash Posted April 26, 2011 Author Share Posted April 26, 2011 Thanks PsaltyDS, it worked just like I want it. I have another question, how do I read ListBox items into an array, for eg: here I want to read the values of listbox $AppsAdded read into an array. Thanks! Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 26, 2011 Share Posted April 26, 2011 You would have to get the count of items, then do a For/Next loop getting each item by index. That would be easy for you to convert to a function like "_GuiCtrlListBox_GetItemArray()". Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now