Jump to content

_GUICtrlListViewSort acting Weird


Recommended Posts

Hello,

I am trying to put together a little gui interface that will allow me to populate information from an SQL database. My problem is that I want to add information into a ListView box by using the _GUICtrlListViewInsertItem which works fine, But I also want the data to be capable of sorting by the column names using _GUICtrlListViewSort. I put together a small sample script that explains my problem.

#include <GUIConstants.au3>
#include <GuiListView.au3>

Const $LVS_SORTDESCENDING = 0x0020
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index
GUICreate("listview items",330,200, 100,200)

$listview = GuiCtrlCreateListView ("Sample One  |Sample two  |Sample Three  ", 10, 10, 310, 149, -1, BitOR($LVS_EX_REGIONAL, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
$button = GuiCtrlCreateButton ("Insert",175,170,70,20)
GuiSetState()
Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview)]
Do
  $msg = GuiGetMsg ()
   Select
   Case $msg = $button
       $x = 0
       Do 
       $InsertList = _GUICtrlListViewInsertItem ($listview, $x, $x & "|" & $x + 1 & "|" & $x + 2)
       $x = $x + 1
       Until $x = 14
    Case $msg = $listview
        _GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))
   EndSelect
Until $msg = $GUI_EVENT_CLOSE

If you click on Insert to populate data, then click on one of the column headers it appears to add blank items at the bottom of the listview, if you resort using another column it looks like the data is wiped out but you need to do is scroll down because it put the blank rows on top. Any ideas how to get around this adding of blank rows?

Thanks,

Mike

Link to comment
Share on other sites

Looks like not a sort problem but a InsertItem problem, The Delete all items function was changed to free up autoits resources when items were deleted,

this seems to have caused some strange behaviour when using insert item.

I'm looking into the problem with insert item, but for now:

#include <GUIConstants.au3>
#include <GuiListView.au3>

Const $LVM_SETEXTENDEDLISTVIEWSTYLE    = 0x1036
Const $LVS_SORTDESCENDING = 0x0020

Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index
GUICreate("listview items",330,200, 100,200)

$listview = GuiCtrlCreateListView ("Sample One  |Sample two  |Sample Three  ", 10, 10, 310, 149)
GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
$button = GuiCtrlCreateButton ("Insert",175,170,70,20)
GuiSetState()
Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview)]
Do
  $msg = GuiGetMsg ()
   Select
   Case $msg = $button
       $x = 0
       Do 
          GUICtrlCreateListViewItem($x & "|" & $x + 1 & "|" & $x + 2, $listview)

;~        $InsertList = _GUICtrlListViewInsertItem ($listview, $x, $x & "|" & $x + 1 & "|" & $x + 2)
       $x = $x + 1
       Until $x = 14
    Case $msg = $listview
        _GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))
   EndSelect
Until $msg = $GUI_EVENT_CLOSE

Edit: found how to fix the delet all items if insert item is used, i'll submit the fix

Gary

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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...