Good morning to all,
I'm starting to work with autoit and I have a problem with the sorting of the listview. I saw that there are many examples in the forum but I could not figure it out. In the example below I want to sort in ascending order the various elements of listview immediately after their insertion but do not understand where I'm wrong
#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <GUIListView.au3>
#include <WindowsConstants.au3>
$Form1_1 = GUICreate("Form1", 200, 300, 200, 200)
$ListView1 = GUICtrlCreateListView("Date", 5, 5, 190, 250)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200)
$Date1 = GUICtrlCreateDate("2013/04/03 14:34:10", 5, 265, 190, 25, 0)
$sortFlag = True
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Date1
$myDate = GUICtrlRead($Date1)
if _GUICtrlListView_FindInText($ListView1, $myDate, -1) = -1 Then
$lvIndex = _GUICtrlListView_GetItemCount($ListView1)
_GUICtrlListView_InsertItem($ListView1, $myDate, $lvIndex)
_GUICtrlListView_SimpleSort($ListView1, $sortFlag, 0)
EndIf
EndSwitch
WEnd
Can anyone help me?
thanks!
Sergio