Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/20/2022 in all areas

  1. Werty

    Hi there, I am Sven

    Hello there, welcome to the forum.
    1 point
  2. ahha

    ListView sorting on date

    Thanks to all for the answers/suggestions. They provided me lots of information and I learned much. Here's my version that does not need to use GUICtrlRegisterListViewSort (thanks @Luke94), does not need a phantom column (thanks @mikell), and takes care of the up/down arrow issue (thanks @pixelsearch). I basically use an array to load listview with MM/DD/YYYY format, then when header is clicked I alter array to YYYYMMDD format, load it back into listview, let listview use the regular sort, then load listview back to the array, convert array back to MM/DD/YYYY format and reload listview. I know a lot of loads/reloads but it's straightforward and I understand it (excuse all the debug statements, it helps me :). Any comments welcomed. #AutoIt3Wrapper_run_debug_mode=Y #include <Debug.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> AutoItSetOption("MustDeclareVars", 1) ;v1a - original ;v1b - creating array that we can array->listview, and listview->array ;v1c - changing $aListView because using _GUICtrlListView_AddArray ;v1d - try using all UDF _ functions as mixing could cause issues ;v1e - cleaning out extraneous code ;v1f - released Global $debug = 0, $g_h_GUI, $g_id_ListView Example() Exit Func Example() Local $idRow1, $idRow2, $idRow3, $i, $j, $iRow, $jCol, $string, $aTemp $g_h_GUI = GUICreate("ListView Sort Question", 300, 200) ;get handle in case we need it later ;$g_id_ListView = _GUICtrlListView_Create($g_h_GUI, "Row#|Name|Date ", 10, 10, 280, 180) ;v1d $g_id_ListView = GUICtrlCreateListView("Row#|Name|Date ", 10, 10, 280, 180) ;v1c $iRow = 5 $jCol = 3 Local $aListView[$iRow][$jCol] = _ [ _ ["#1","Alice","01/15/2022"] , _ ["#2","Bob","02/22/2021"] , _ ["#3","Carol","03/13/2021"] , _ ["#10","Dave","10/09/2021"] , _ ["#11","Eve","11/21/2021"] _ ] ;_DebugArrayDisplay($aListView) _GUICtrlListView_AddArray($g_id_ListView, $aListView) ;load listview GUISetState(@SW_SHOW) ;$vCompareType = 0 ;not ok as Row# sort #1, #10, and want #1, #2, ;$vCompareType = 1 ;not ok as Row# sort #1, #10, and want #1, #2, Local $vCompareType = 2 ;Row# okay but Date messed up _GUICtrlListView_RegisterSortCallBack($g_id_ListView, $vCompareType) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $g_id_ListView ;Pause("col="&GUICtrlGetState($g_id_ListView)) If GUICtrlGetState($g_id_ListView) = 2 Then ;date column so we do a special sort For $i = 0 to $iRow - 1 ;overwrite in array col MM/DD/YYYY with YYYYMMDD for sorting purposes $string = $aListView[$i][2] ;initially MM/DD/YYYY format $string = StringRight($string, 4) & StringLeft($string, 2) & StringMid($string, 4, 2) ;now in YYYYMMDD format $aListView[$i][2] = $string ;stuff into array Next If $debug <> 0 Then _DebugArrayDisplay($aListView, "$aListView after converting to YYYYMMDD format") _GUICtrlListView_DeleteAllItems($g_id_ListView) ;clear out listview Pause("Listview cleared") _GUICtrlListView_AddArray($g_id_ListView, $aListView) ;reload listview from array Pause("Listview reloaded with YYYYMMDD date format") _GUICtrlListView_SortItems($g_id_ListView, GUICtrlGetState($g_id_ListView)) ;use standard sort Pause("Standard sort used on YYYYMMDD date format") For $i = 0 to $iRow - 1 ;get each row of listview into array $aTemp = _GUICtrlListView_GetItemTextArray($g_id_ListView, $i) ;get row $i into $aTemp [0] has count For $j = 1 to $aTemp[0] $aListView[$i][$j - 1] = $aTemp[$j] ;stick it back into $aListView Next Next If $debug <> 0 Then _DebugArrayDisplay($aListView, "After loop: $aListView after reading $g_id_ListView") ;now convert YYYYMMDD in array to MM/DD/YYYY format then load array into listview For $i = 0 to $iRow - 1 ;overwrite in array col YYYYMMDD with MM/DD/YYYY $string = $aListView[$i][2] ;YYYYMMDD format $string = StringMid($string, 5, 2) &"/"& StringRight($string, 2) &"/"& StringLeft($string, 4) ;now in MM/DD/YYYY format $aListView[$i][2] = $string ;stuff into array Next If $debug <> 0 Then _DebugArrayDisplay($aListView, "$aListView after YYYYMMDD to MM/DD/YYYY") ;now stuff back into listview _GUICtrlListView_DeleteAllItems($g_id_ListView) ;clear out listview _GUICtrlListView_AddArray($g_id_ListView, $aListView) ;reload listview from array Pause("Listview reloaded with MM/DD/YYYY date format") Else ;use standard sort _GUICtrlListView_SortItems($g_id_ListView, GUICtrlGetState($g_id_ListView)) ;use standard sort EndIf EndSwitch WEnd _GUICtrlListView_UnRegisterSortCallBack($g_id_ListView) GUIDelete($g_id_ListView) EndFunc ;Func Example() Func Pause($text="") If $debug <> 0 Then MsgBox(262144, "DEBUG", "Paused: " & $text) EndFunc
    1 point
  3. welcome to the forum
    1 point
  4. I just submit: https://userstyles.world/style/2841/autoit-for-github-com This is how it looks on GitHub: and here are CSS: div.highlight-source-autoit pre { font-weight: bold; } div.highlight-source-autoit span.pl-c1 { color: blue !important; } div.highlight-source-autoit span.pl-s { color: green !important; } div.highlight-source-autoit span.pl-smi { color: chocolate !important; } div.highlight-source-autoit span.pl-pds { color: black !important; } div.highlight-source-autoit span.pl-c { color: darkgray !important; } div.highlight-source-autoit span.pl-k { color: purple !important; } table[data-tagsearch-lang~="AutoIt"] { font-weight: bold; } table[data-tagsearch-lang~="AutoIt"] span.pl-c1 { color: blue !important; } table[data-tagsearch-lang~="AutoIt"] span.pl-s { color: green !important; } table[data-tagsearch-lang~="AutoIt"] span.pl-smi { color: chocolate !important; } table[data-tagsearch-lang~="AutoIt"] span.pl-pds { color: black !important; } table[data-tagsearch-lang~="AutoIt"] span.pl-c { color: darkgray !important; } table[data-tagsearch-lang~="AutoIt"] span.pl-k { color: purple !important; }
    1 point
  5. Latest update just released. See below for change log.
    1 point
  6. @markyrocks, I like the attention to detail and exploration of possibilities when looking at the array functions we have to work with. But on the other hand ( there's a golden band .. ) the hint of money exchange for a product that is itself free.., not cool. The devs don't need this product, but I do, due to not knowing different or being mentality limited, either/or, is the same to me. I would have to learn programming, if not for AutoIt. Again, I like what your doing, but your people skills .. is confrontational. And is very probably that confrontational nature that pushed you to look for a solution to the slow array handling in AutoIt, so is not bad as a nature. I do make money with the code I do for clients using AutoIt ( coffee and cigarettes are not free ) but when I can share something with this community that I feel is needed, I do. In itself is a form of donation in my view ( but I suffer cognitive dissonance from time to time, so my mile may vary ). If you're posting in this forum is because you are fond of AutoIt and any favorable contribution ( without ranting much if possible ) will always be welcomed in my book.
    1 point
  7. When you got skillz you don't need luck son.
    1 point
×
×
  • Create New...