Emiel Wieldraaijer Posted September 11, 2014 Share Posted September 11, 2014 (edited) Hi All, I'm trying to sort a Listview with checkboxes...looks likes it works fine.. everything looks sorted But i have a little problem which i cannot solve (I believe i am the problem ) If you run the code below and follow the steps - Select the fourth checkbox and press "Show checked" button it will display the right result in a messagebox. - Sort by pressing field C and you will see the checkbox moves to the first position, still correct - Press the button "Show checked" and it displays the information which was before the sorting on the first position.. this is correct because the code isn't correct..how can i read the content of the line which is checked instead of the wrong line or just one column. Or is the only solution to read all the column if you want the complete line ?!!! expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> Dim $sListViewItem[500] GUICreate("Sorting with CheckBoxes", 400, 480) $sListView = GUICtrlCreateListView("Select|A|B|C|D|E", 20, 20, 360, 400) _GUICtrlListView_SetExtendedListViewStyle($sListview, $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($sListView, 0, 60) _GUICtrlListView_SetColumnWidth($sListView, 1, 60) _GUICtrlListView_SetColumnWidth($sListView, 2, 60) _GUICtrlListView_SetColumnWidth($sListView, 3, 60) _GUICtrlListView_SetColumnWidth($sListView, 4, 60) _GUICtrlListView_SetColumnWidth($sListView, 5, 60) $sListviewItem[0] = GUICtrlCreateListViewItem("|111|222|333|444|555", $sListView) $sListviewItem[1] = GUICtrlCreateListViewItem("|222|333|444|555|111", $sListView) $sListviewItem[2] = GUICtrlCreateListViewItem("|333|444|555|111|222", $sListView) $sListviewItem[3] = GUICtrlCreateListViewItem("|444|555|111|222|333", $sListView) $sListviewItem[4] = GUICtrlCreateListViewItem("|555|111|222|333|444", $sListView) $sButton = GUICtrlCreateButton("Show checked", 280, 440, 100,20) GUISetState () _GUICtrlListView_RegisterSortCallBack($sListView) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE _GUICtrlListView_UnRegisterSortCallBack($sListView) Exit Case $msg = $sButton For $i = 0 to 4 If _GUICtrlListView_GetItemChecked($sListView, $i) = "true" Then ; the following is off course the problem because it reads the incorrect row msgbox (64, "Checked value", GUICtrlRead($sListViewItem[$i])) ; the following only checks one column, how to retrieve the whole line msgbox (64, "Checked value", _GUICtrlListView_GetItemText($sListView, $i, 1)) EndIf Next Case $msg = $sListView _GUICtrlListView_SortItems($sListView, GUICtrlGetState($sListView)) EndSelect Wend Edited September 11, 2014 by Emiel Wieldraaijer Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
mikell Posted September 11, 2014 Share Posted September 11, 2014 (edited) ? Case $msg = $sButton For $i = 0 to 4 If _GUICtrlListView_GetItemChecked($sListView, $i) = "true" Then $txt = _GUICtrlListView_GetItemTextString($sListView, $i) Msgbox(0,"", $txt) ; $array = _GUICtrlListView_GetItemTextArray($sListView, $i) ; _ArrayDisplay($array) EndIf Next Edited September 11, 2014 by mikell Link to comment Share on other sites More sharing options...
Danyfirex Posted September 11, 2014 Share Posted September 11, 2014 for Best coding practices when you check If _GUICtrlListView_GetItemChecked($sListView, $i) = "true" Then. Use a bool value. not a string "true" Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
mikell Posted September 11, 2014 Share Posted September 11, 2014 Msgbox(0,"", (2*5=10) ) Link to comment Share on other sites More sharing options...
Danyfirex Posted September 11, 2014 Share Posted September 11, 2014 Msgbox(0,"", (2*5=10) ) @mikell ¿what's your point? saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
mikell Posted September 11, 2014 Share Posted September 11, 2014 I am not convinced that using "true" instead of 1 - or any number <> 0 - is of bad practice About booleans the helpfile doesn't mention that one use is better than the other Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted September 11, 2014 Author Share Posted September 11, 2014 As i said .. .it's probally me .. _GUICtrlListView_GetItemTextString is the solution Thanks Best regards,Emiel Wieldraaijer 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