Jump to content

Search the Community

Showing results for tags 'number sorting'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I was reading the Helpfile on both GUICtrlRegisterListViewSort and _GUICtrlListView_SimpleSort, and after running my script, I was initially satisfied with the way columns are sorted when the user clicks on the column header. But at certain occasions, clicking on the column header to sort numbers - integers in particular - seem to have some unexpected behaviour. I cannot verify if it is due to the way I wrote the script, or because the functions used in AutoIt to sort numbers intentionally work the way they do. Example: Column ID | Item ID | Item Name | Date 1 | ID_1 | One | 14/05/2014 2 | ID_2 | Two| 14/05/2014 3 | ID_3 | Three| 14/05/2014 10 | ID_4 | Four| 14/05/2014 9 | ID_5 | Five| 14/05/2014 27 | ID_6 | Siz| 15/05/2014 When the user clicks Column ID, logically the order of ascending sorting would look like this: 1, 2, 3, 9, 10, 27 But what I got is like this: 1, 10, 2, 27, 3, 9 Does anyone know the reason behind the way it is sorted this way? How then do I get the columns to be sorted correctly when the user clicks the column header? (I did read across other related threads like and ) I attached my codes here to see if I might write them wrongly. My code for generating ListView: $inventoryList = GUICtrlCreateListView("ID|item id|item name| Date", 45, 140, expandGUIX(750), expandGUIY(450), $LVS_REPORT, BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)) _GUICtrlListView_SetColumnWidth(-1, 3, 651) $hInventoryList = GUICtrlGetHandle($inventoryList) For $i = 0 To 3 _GUICtrlListView_SetColumnWidth($inventoryList, $i, $LVSCW_AUTOSIZE_USEHEADER) Next My code for auto-resizing columns: Func resizeColumns($hWnd, $listView, $iColumns, $iGUI_Width, $iGUI_Height) ; Check top index - if not 0 then we have a scroll bar so increase ListView width Local $iScroll_Allowance If _GUICtrlListView_GetTopIndex($listView) > 0 Then $iScroll_Allowance = 17 EndIf ; Determine ListView width Local $iLV_Width = $iScroll_Allowance Local $iData_Width, $iHeader_Width Local $i = 0 For $i = 0 To $iColumns - 1 ; Size column to fit header _GUICtrlListView_SetColumnWidth($listView, $i, $LVSCW_AUTOSIZE_USEHEADER) $iHeader_Width = _GUICtrlListView_GetColumnWidth($listView, $i) ; Now size column to fit data _GUICtrlListView_SetColumnWidth($listView, $i, $LVSCW_AUTOSIZE) $iData_Width = _GUICtrlListView_GetColumnWidth($listView, $i) ; If header is wider, reset width If $iHeader_Width > $iData_Width Then _GUICtrlListView_SetColumnWidth($listView, $i, $iHeader_Width) $iLV_Width += $iHeader_Width Else $iLV_Width += $iData_Width EndIf Next ; Resize ListView and GUI to fit data ControlMove($hWnd, "", $listView, 10, 10, $iLV_Width + 10, $iGUI_Height - 20) ; Add 10 for internal ListView borders EndFunc ;==>resizeColumns My code for locking users from resizing columns after auto-resize: Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Get details of message Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam) ; Look for header resize code $iCode = DllStructGetData($tNMHEADER, "Code") Switch $iCode Case $HDN_BEGINTRACKW ; Prevent resizing Return True Case $LVN_COLUMNCLICK ; Sort column $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) $iCol = DllStructGetData($tInfo, "SubItem") _GUICtrlListView_SimpleSort($cListView, $g_bSortSense, $iCol) EndSwitch Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY
×
×
  • Create New...