Jump to content

[Solved] Why is my listview in inverted order?


qwert
 Share

Recommended Posts

From a post a couple of years ago:

Quote

GUICtrlCreateListViewItem places newly created ListViewItems right below the older ones.

This is the result I want. But no matter which "add item" statement I use, the result always displays in descending (not ascending) order.

;
;       Array and Listview Test
;
#include <GuiListView.au3>
#include <Array.au3>

Local $aArray[4]
$aArray[0] = "Jasper"
$aArray[1] = "Beethoven"
$aArray[2] = "Pinky"
$aArray[3] = "Fidget"

_ArrayDisplay($aArray)

_ArraySort($aArray)
_ArrayDisplay($aArray)

GUICreate("Array and ListView Test", 300, 300)
GUISetFont(12)
$idListview = GUICtrlCreateListView("", 20, 20, 250, 220, 50)
_GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))

For $i = 0 To UBound($aArray) - 1 Step 1
MsgBox(0, "Next", $aArray[$i])
GUICtrlCreateListViewItem($aArray[$i], $idListview)
Next

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMSG()
        Case -3 ; $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
    EndSwitch
WEnd

Thanks in advance for any help.

Edited by qwert
Link to comment
Share on other sites

  • Moderators

qwert,

Your parameters for the  GUICtrlCreateListView call are wrong - you are setting a style of 50 which is probably the cause of the problem. This works for me:

#include <GuiListView.au3>
#include <Array.au3>

Local $aArray[4]
$aArray[0] = "Jasper"
$aArray[1] = "Beethoven"
$aArray[2] = "Pinky"
$aArray[3] = "Fidget"

_ArrayDisplay($aArray)
_ArraySort($aArray)
_ArrayDisplay($aArray)

GUICreate("Array and ListView Test", 300, 300)
GUISetFont(12)
$idListview = GUICtrlCreateListView(" ", 20, 20, 250, 250) ; You need at least one pixel for a column...
_GUICtrlListView_SetColumnWidth($idListview, 0, 230)       ; ...which you can expand like this
_GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))

For $i = 0 To UBound($aArray) - 1 Step 1
    MsgBox(0, "Next", $aArray[$i])
    GUICtrlCreateListViewItem($aArray[$i], $idListview)
Next

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3 ; $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
    EndSwitch
WEnd

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Melba23, thanks. Indeed, that resolves the order.

I don't rightly know where I got the 50 from ... but I seem to remember it had something to do with "no header".

Do proper Listviews always have headers? This (but not inverted) is the result I'm after:

5bcce92171fb8_ListviewTest.PNG.83d7b0551ba81061f0696e0999dabc79.PNG

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