spin0us Posted May 30, 2011 Share Posted May 30, 2011 (edited) I've made some search but found nothing. I've a list (GUICtrlCreateList) with some (around 400) items in it. User can multi select item from this list. Clicking on a specific picture remove all selected item from the list. - getting all selected item : no problem - removing 1 selection item : no problem - removing multi selection items : bug Removing item change the others items id. So, i tried using _GUICtrlListBox_BeginUpdate and _GUICtrlListBox_EndUpdate, but it's the same bug. Is there another way to remove many items from a list control at one time ? Edited May 30, 2011 by spin0us Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted May 30, 2011 Share Posted May 30, 2011 (edited) What "items id"? Like the zero-based index? What if you delete from the end and go backwards?For $iX = _GUICtrlListBox_GetCount To 0ListDeleteNextAlso, some advice for the future. When asking a question, you should make a reproducer (short, working example). Not only will it help us understand more exactly what it is you are talking about, you will sometimes find the answer to the problem yourself when writing it, due to only the essential parts of the error being there (if you wrote a good reproducer).Edit: mehEdit2: FYI, when _GUICtrlListBox_BeginUpdate says "Prevents updating of the control" they mean it stops redrawing. Speeds up larger actions simply. Edited May 30, 2011 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
KaFu Posted May 30, 2011 Share Posted May 30, 2011 If multi selection really changes the ID, how about sorting the array of IDs from highest to lowest first before removing them? OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
spin0us Posted May 30, 2011 Author Share Posted May 30, 2011 Thanks for your replies. I've already test the backwards solution but it does not work anymore. I will try to use a temp array to store items, work on array and put array back in list. It seems to be the only available fix Link to comment Share on other sites More sharing options...
KaFu Posted May 30, 2011 Share Posted May 30, 2011 ;#include <Array.au3> #include <GUIListBox.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> $hGUI = GUICreate("(UDF Created) List Box Create", 400, 296) $hListBox = _GUICtrlListBox_Create($hGUI, "String upon creation", 2, 2, 396, 270, $LBS_EXTENDEDSEL) GUISetState() ; Add files _GUICtrlListBox_BeginUpdate($hListBox) _GUICtrlListBox_ResetContent($hListBox) _GUICtrlListBox_InitStorage($hListBox, 100, 4096) _GUICtrlListBox_Dir($hListBox, @WindowsDir & "\win*.exe") _GUICtrlListBox_AddFile($hListBox, @WindowsDir & "\Notepad.exe") _GUICtrlListBox_Dir($hListBox, "", $DDL_DRIVES) _GUICtrlListBox_Dir($hListBox, "", $DDL_DRIVES, False) _GUICtrlListBox_EndUpdate($hListBox) $bRemove = GUICtrlCreateButton("Remove", 10, 260) ; Loop until user exits While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $bRemove $a_SelectedItems = _GUICtrlListBox_GetSelItems($hListBox) ;_ArrayDisplay($a_SelectedItems) For $i = $a_SelectedItems[0] To 1 Step -1 _GUICtrlListBox_DeleteString($hListBox, $a_SelectedItems[$i]) Next EndSwitch WEnd OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
spin0us Posted May 30, 2011 Author Share Posted May 30, 2011 Thank you very much. I wasted my time on a f..... syntax error hide in the backward for loop. 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