supersonic Posted April 2, 2009 Posted April 2, 2009 Hi! I'm trying to delete all columns of a ListView. The columns count could differ. To delete the columns I use a function: Func _GUICtrlListView_DeleteAllColumns($hWnd) For $i = 0 To _GUICtrlListView_GetColumnCount($hWnd) Step 1 ConsoleWrite($i & @CRLF) _GUICtrlListView_DeleteColumn($hWnd, $i) Next EndFunc Before the for-loop starts _GUICtrlListView_GetColumnCount() returns 29 columns. After _GUICtrlListView_GetColumnCount() returns 14 columns. What's wrong? May someone could help? Greets, -supersonic.
Authenticity Posted April 2, 2009 Posted April 2, 2009 #include <GuiConstantsEx.au3> #include <GuiListView.au3> Dim $hGUI = GUICreate('Test', 300, 400) Dim $hListView = _GUICtrlListView_Create($hGUI, '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15', 0, 0, 300, 300) Dim $Button = GUICtrlCreateButton('Delete', 215, 340, 70, 25) GUISetState() While 1 Switch GUIGetMsg() Case -3 ExitLoop case $Button DeleteColumns($hListView) GUICtrlSetState($Button, $GUI_DISABLE) EndSwitch Sleep(40) WEnd GUIDelete() Func DeleteColumns($hLV) Local $iColumn = _GUICtrlListView_GetColumnCount($hLV) For $i = $iColumn-1 To 0 Step -1 _GUICtrlListView_DeleteColumn($hLV, $i) Next EndFunc VenusProject2 1
supersonic Posted April 2, 2009 Author Posted April 2, 2009 Ahhh... I got it! :-) Thank you. #include <GuiConstantsEx.au3> #include <GuiListView.au3> Dim $hGUI = GUICreate('Test', 300, 400) Dim $hListView = _GUICtrlListView_Create($hGUI, '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15', 0, 0, 300, 300) Dim $Button = GUICtrlCreateButton('Delete', 215, 340, 70, 25) GUISetState() While 1 Switch GUIGetMsg() Case -3 ExitLoop case $Button DeleteColumns($hListView) GUICtrlSetState($Button, $GUI_DISABLE) EndSwitch Sleep(40) WEnd GUIDelete() Func DeleteColumns($hLV) Local $iColumn = _GUICtrlListView_GetColumnCount($hLV) For $i = $iColumn-1 To 0 Step -1 _GUICtrlListView_DeleteColumn($hLV, $i) Next EndFunc
WideBoyDixon Posted April 2, 2009 Posted April 2, 2009 Another example: Func _GUICtrlListView_DeleteAllColumns($hWnd) While _GUICtrlListView_GetColumnCount($hWnd) > 0 _GUICtrlListView_DeleteColumn($hWnd, 0) Wend EndFunc ;==>_GUICtrlListView_DeleteAllColumns It's generally not a good idea to use a For loop when removing items from collections. I wonder whether the target value of the for loop is calculated only once at the beginning and not re-evaluated for each iteration of the loop or whether it's dynamic ... [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
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