List view sortieren

  • Hallo Zusammen,

    ich brauche eure Hilfe bei der Sortierung einer List View. Ich steig nicht ein wie das gehen soll.
    Ich habe eine Beispiel Gui erstellt, die nach Namen oder Alter sortieren soll.

    Hat wer einen kleinen Tipp.

    Spoiler anzeigen

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    #Include <GuiListView.au3>


    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 631, 205, 192, 114)
    $ListView1 = GUICtrlCreateListView("Name|Alter", 112, 24, 378, 78)
    GUICtrlCreateListViewItem("Hans|40",$ListView1 )
    GUICtrlCreateListViewItem("Tim|20",$ListView1 )
    GUICtrlCreateListViewItem("Tom|30",$ListView1 )
    $Button1 = GUICtrlCreateButton("Button1", 240, 136, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    case $Button1
    _GUICtrlListView_SimpleSort($ListView1)


    EndSwitch
    WEnd

  • Halli Hallo Hallöchen!

    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    #Include <GuiListView.au3>
    #include <ListViewConstants.au3>

    [/autoit][autoit][/autoit][autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 631, 205, 192, 114)
    $ListView1 = GUICtrlCreateListView("Name|Alter", 112, 24, 378, 78)
    GUICtrlCreateListViewItem("Hans|40",$ListView1 )
    GUICtrlCreateListViewItem("Tim|20",$ListView1 )
    GUICtrlCreateListViewItem("Tom|30",$ListView1 )
    $Button1 = GUICtrlCreateButton("Button1", 240, 136, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($listview1)]

    [/autoit][autoit][/autoit][autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    case $Button1
    _GUICtrlListView_SimpleSort($ListView1, $b_DESCENDING, 1)

    [/autoit][autoit][/autoit][autoit]

    EndSwitch
    WEnd

    [/autoit]


    So wirds nach dem Alter geordnet.
    Wenn man den 3. Parameter von Simplesort auf 0 setzt, wird nach Namen geordnet-
    Gruß,
    Billie

    [align=center]Meine Werke mit der Irrlicht Engine
    AutoIt Picture Viewer Dreidimensionaler Bildbetrachter
    Mr Bubble 3D Neue Interpretation des Flashklassikers Bubble trouble

    • Offizieller Beitrag
    Bsp.
    [autoit]

    #include <ListViewConstants.au3>
    #include <StructureConstants.au3>
    #include <GuiConstantsEx.au3>
    #include <GuiListView.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt('MustDeclareVars', 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hListView, $B_DESCENDING
    GUICreate("ListView SimpleSort by Column Click", 400, 300)
    $hListView = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
    GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
    GUICtrlCreateListViewItem("line4|5|more_a", $hListView)
    GUICtrlCreateListViewItem("line5|4.50 |more_c", $hListView)
    GUICtrlCreateListViewItem("line5|4.0 |more_c", $hListView)
    GUICtrlCreateListViewItem("line3|23|more_e", $hListView)
    GUICtrlCreateListViewItem("line2|0.34560 |more_d", $hListView)
    GUICtrlCreateListViewItem("line1|1.0 |more_b", $hListView)
    GUICtrlCreateListViewItem("line1|0.1 |more_b", $hListView)
    GUICtrlCreateListViewItem("line1|10|more_b", $hListView)
    _GUICtrlListView_SetColumnWidth($hListView, 0, 75)
    _GUICtrlListView_SetColumnWidth($hListView, 1, 75)
    _GUICtrlListView_SetColumnWidth($hListView, 2, 75)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($hListView)]

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    [/autoit] [autoit][/autoit] [autoit]

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    If ($hWndFrom = $hWndListView) And ($iCode = $LVN_COLUMNCLICK) Then
    $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    _GUICtrlListView_SimpleSort($hWndListView, $B_DESCENDING, DllStructGetData($tInfo, "SubItem"))
    EndIf
    EndFunc ;==>WM_NOTIFY

    [/autoit]