Arctor Posted June 6, 2004 Posted June 6, 2004 Hi all, can anyone take a look at this? I can't get it to delete an Item from the list. FileChangeDir(@ScriptDir) GUICreate("zzz", 320, 260) $Listbox1 = GuiSetControl ("list", "", 10,20,300,200) $AddDir = GUISetControl ("button", "Add Dir", 10,210,100,20) GuiSetControlNotify() $DelItem = GUISetControl ("button", "Del Item", 110,210,100,20) GuiSetControlNotify() $ClearList = GUISetControl ("button", "Clear List", 210,210,100,20) GuiSetControlNotify() ;------------------------------------------------- While GUIMsg() > 0 if GuiRead () = $AddDir Then $dirpath = FileSelectFolder("Choose a directory.", "", 0) If @error <> 1 AND $dirpath <> "" Then GUISetControlData($Listbox1, $dirpath) EndIf EndIf if GuiRead () = $DelItem Then $selitem = GuiRead($Listbox1) ;;;missing code to remove the selected item from the list EndIf if GuiRead () = $ClearList Then GUISetControlData($Listbox1, "") EndIf Wend If I use "ControlCommand" with the command "DelString", I can only delete the first Item in the List. Although the Documentation is one of the best I ever saw, I can't find it. I already searched this Forum and also yahoo.group. It would also be nice to know: Is it possible to change the value of an item in the list? But thats not the way important as to delete one. arctor
Josbe Posted June 6, 2004 Posted June 6, 2004 (edited) There are some ways. One: You can use GUISetControlData() for refresh with a StringReplace inside. Edited June 6, 2004 by josbe AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
Valik Posted June 6, 2004 Posted June 6, 2004 If there are no duplicate entries, then you can ead the selected string with GuiRead(). Then use ControlCommand with "FindString" to get the occurence, then you can use that occurence with DelString. It's a long way about it, but it works.
Arctor Posted June 6, 2004 Author Posted June 6, 2004 There are some ways. One: You can use GUISetControlData() for refresh with a StringReplace inside.Hi josbe, thx for the quick answer. Can't get the syntax for your suggestion. But it brought me to another solution. $selitem = GuiRead($Listbox1) $item2delete = ControlCommand ( "zzz", "", "ListBox1", "FindString", $selitem) ControlCommand ( "zzz", "", "ListBox1", "DelString", $item2delete)This works for me. You can use GUISetControlData() for refresh with a StringReplace inside.Can you give an example for that? I'm aways looking for solutions, that fits in 1 line. ;-) There are some ways.Another one? hehe arctor
Arctor Posted June 6, 2004 Author Posted June 6, 2004 If there are no duplicate entries, then you can ead the selected string with GuiRead(). ...Hi Valik,what you said is exactly what I just found.I tested it with duplicate and like duplicate entries. It will delete only one of themarctor
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