sulfurious Posted July 1, 2008 Posted July 1, 2008 Greets. I have been pounding on this one for awhile now. I have been using _GuiCtrlListView_DeleteAllItems() to clear out my LV. Then fill it with new data. You know, works like it should. My recent script suddenly has one spot where the delete does not complete before the next fill happens. I have an array of say 1200 items populating the list view. I have a context menu that basically says to filter the array based on criteria and then delete the items from the listview and then repopulate from the filtered array. The problem is that if I have 1500 entries in the list view, it seems to not delete before the script continues to refilling it. I have tried sleep() and do/until while/wend loops, but the script must stop the delete action as well as it does not seem to work. Many of my scripts don't have tis problem, just this one it seems. Here are some snips of the code. First we have the calling function, which here basically I have triggered from a context menu on the lv. cIS fetches the ID and Handle for the listview. _ArrayAddArrayEX() is my func to add an array index (multi D) to another array (multi D). Func _pwfFILTER($meNUM) Local $lv = cIS('lvFWLogs') Local $lvH = cIS('lvFWLogs',True) Local $vH,$vIndex $vH = _GUICtrlListView_GetItemTextArray($lv) If $vH = '' Then Return; check for not array Dim $avFILTERED[1][6] _GUICtrlListView_DeleteAllItems($lv) If $meNUM = 1 Then; src $vIndex = $vH[2] For $i = 1 To $avSPPFW[0][0] If $avSPPFW[$i][1] = $vIndex Then _ArrayAddArrayEX($avFILTERED,$avSPPFW,$i,True,6) Next _lvPopulate($avFILTERED,$lv,6) ElseIf $meNUM = 2 Then; dst $vIndex = $vH[4] For $i = 1 To $avSPPFW[0][0] If $avSPPFW[$i][3] = $vIndex Then _ArrayAddArrayEX($avFILTERED,$avSPPFW,$i,True,6) Next _lvPopulate($avFILTERED,$lv,6) ElseIf $meNUM = 3 Then; clear _lvPopulate($avSPPFW,$lv,6) EndIf ;~ _ArrayDisplay($avFILTERED) EndFunc Here is the function that i fill the listview with. Func _lvPopulate(ByRef $avArray,ByRef $hLV,$iCol=1); Pass array, listview, # cols to fill. Single or Multi dimensions based on iCol #. If Not IsArray($avArray) Then Return SetError(1,0,-1) _GUICtrlListView_BeginUpdate($hLV) If $iCol = 1 Then For $i = 1 To UBound($avArray) - 1 _GUICtrlListView_AddItem($hLV,$avArray[$i]) Next ElseIf $iCol > 1 Then For $i = 1 To UBound($avArray) - 1 _GUICtrlListView_AddItem($hLV,$avArray[$i][0]) For $x = 1 To $iCol - 1 _GUICtrlListView_AddSubItem($hLV,$i - 1,$avArray[$i][$x],$x) Next Next EndIf _GUICtrlListView_EndUpdate($hLV) EndFunc I am fresh out of ideas. Anyone see something I don't? Sul.
nobbe Posted July 1, 2008 Posted July 1, 2008 (edited) you could try to delete the control and setup a new one? Edited July 1, 2008 by nobbe
sulfurious Posted July 1, 2008 Author Posted July 1, 2008 Yes, deleting the control would work, but I am trying to figure out why it does it so I can avoid such errors in the future. Thank you though. Sul.
sulfurious Posted July 2, 2008 Author Posted July 2, 2008 Problem occurs over and over when in a function. Delete the listview items, then immediately step through an array to re-populate gives unexpected results. I have fixed this issue by creating a function to delete, and call that from the main func. This evidentily does not return until the delete is actually complete, thus solving the problem. Sul.
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