Jump to content

Problem with _GUiCtrlLIstView_DeleteAllItems & Sort


Recommended Posts

This is odd. I need a listview that will be able to sort, as well as clear. It seems that GUICtrlListViewCreate can do the sorting and _GUICtrlLIstView_Create can do the clearing, however they don't seem to be able to work together. Any ideas?

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $hListView, $hLIstView2
Global $gui, $btn

$gui = GUICreate("ListView Sort", 600, 300)
$hListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180);, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS))
$hListView2 = _GUICtrlListView_Create($gui, "Column1|Col2|Col3", 310, 10, 280, 180);, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS))

_AddRow($hListView, "ABC|000666|10.05.2004")
_AddRow($hListView, "DEF|444|11.05.2005")
_AddRow($hListView, "CDE|555|12.05.2004")
_AddRow($hListView2, "ABC|000666|10.05.2004")
_AddRow($hListView2, "DEF|444|11.05.2005")
_AddRow($hListView2, "CDE|555|12.05.2004")

$btn = GUICtrlCreateButton('Clear', 10, 200, 100, 25) 

_GUICtrlListView_RegisterSortCallBack($hListView)
_GUICtrlListView_RegisterSortCallBack($hListView2)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $hListView, $hListView2
            Msgbox(0, '', 'The Listview on the left will sort, it wass created with GUICtrlListView' & @CRLF & @CRLF _
                & 'The Listview on the right will not sort, it was created with _GUICtrlListView_Create, in fact you can not even try to sort it.')
            _GUICtrlListView_SortItems($hListView, GUICtrlGetState($hListView))
        Case $btn 
            Msgbox(0, '', 'The Listview on the left will not clear, it was created with GUICtrlListView' & @CRLF & @CRLF _
                & 'The Listview on the right will clear, it was created with _GUICtrlListView_Create')
            _GUICtrlListView_DeleteAllItems($hListView)
            _GUICtrlListView_DeleteAllItems($hListView2)
    EndSwitch
WEnd

_GUICtrlListView_UnRegisterSortCallBack($hListView)
_GUICtrlListView_UnRegisterSortCallBack($hListView2)
GUIDelete()

Func _AddRow($hWnd, $sItem)
    Local $aItem = StringSplit($sItem, "|")
    Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], -1, _GUICtrlListView_GetItemCount($hWnd) + 9999)

    For $x = 2 To $aItem[0]
        _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1)
    Next
EndFunc  ;==>_AddRow
Edited by Achilles
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...