Phenom Posted June 10, 2010 Share Posted June 10, 2010 Listview automatically displays things in sorted order. Is there a way to get it to show things in the order that they're added? If not then is there something similar that can do it? I tried putting a 0 in as the last parameter to GuiCtrlCreateList, and it seemed to work, but the problem is that the slider on the side is disabled, so when it gets full no new information is added. Also, if it sees something that already exists in the listview, it doesn't add it it just highlights it. What I'm trying to do is create a status box. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 10, 2010 Moderators Share Posted June 10, 2010 Phenom, Listview automatically displays things in sorted orderOh no it does not! You have to use the $LVS_SORTASCENDING or $LVS_SORTDESCENDING styles to get a ListView to sort. Take a look at this - is is sorted for you? It certainly is not for me! #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hLV = GUICtrlCreateListView("Header", 10, 10, 400, 450) For $i = 1 To 20 GUICtrlCreateListViewItem(Chr(Random(65, 90, 1)), $hLV) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd If you add the styles I mentioned above, it will display sorted data - but remember that you will have to also re-add the default styles if you wish to retain them. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Phenom Posted June 10, 2010 Author Share Posted June 10, 2010 This one does. #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hLV = GUICtrlCreateList("",10, 10, 400, 450) For $i = 1 To 20 GUICtrlSetData($hLV, Chr(Random(65, 90, 1))) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd What's the difference between a List and a ListView? How can I get your code to automatically scroll the window when more data is added to the end? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 10, 2010 Moderators Share Posted June 10, 2010 Phenom,There are BIG differences between a List and a ListView. A List has only one element per line, no headers and cannot be sorted dynamically - all of which a ListView can do. You need to be careful not to mix the two - they are very different beasts. Your List will sort automatically because the default styles for a List include $LBS_SORT - you need to redeclare the styles without it to prevent sorting:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) $hLV = GUICtrlCreateList("",10, 10, 400, 450, BitOr($WS_BORDER, $WS_VSCROLL)) For $i = 1 To 20 GUICtrlSetData($hLV, Chr(Random(65, 90, 1))) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndAs to scrolling to the last entry in a ListView, you need to use the GUIListView UDF like this:#include <GUIConstantsEx.au3> #include <GuiListView.au3> $hGUI = GUICreate("Test", 500, 500) $hLV = GUICtrlCreateListView("Header", 10, 10, 400, 250) GUISetState() For $i = 1 To 20 GUICtrlCreateListViewItem(Chr(Random(65, 90, 1)), $hLV) _GUICtrlListView_EnsureVisible($hLV, $i - 1) Sleep(500) ; Just so you can see it happening before your very eyes! Next While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndThere are loads of very interesting functions in the GUIListView UDF, but many of them require you to create the ListView with the UDF functions rather than the built-in commands. However, as you can see here, some work either way. All clear now? M23 shaqan 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Phenom Posted June 10, 2010 Author Share Posted June 10, 2010 The code for the List works better now but it's still not adding duplicate entries. Is there a way to fix that? For the second parameter of _GUICtrlListView_EnsureVisible(), if you're not keeping track of it with a variable is there some other thing you can put in there to make it work? Also, don't you think it's strange that the syntax for the parameters of these two functions are opposite? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 11, 2010 Moderators Share Posted June 11, 2010 Phenom, If you want duplicate entries in a list, you need to create a string of the entries and then set them all at once. Otherwise you do not get duplicates - as you discovered: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) $hLV = GUICtrlCreateList("",10, 10, 400, 450, BitOr($WS_BORDER, $WS_VSCROLL)) $sData = "" For $i = 1 To 20 $sData &= Chr(Random(65, 67, 1)) & "|" ; Do not forget to add the delimiter! Next GUICtrlSetData($hLV, $sData) ; Set them all at once GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd don't you think it's strange that the syntax for the parameters of these two functions are opposite?Do you mean these: GUICtrlCreateListViewItem(Chr(Random(65, 90, 1)), $hLV) _GUICtrlListView_EnsureVisible($hLV, $i - 1) Well, the first is a built-in AutoIt function while the second is from the GUIListView UDF, so you had best ask the author of the UDF. I have no problem with them as they are - I usually look up the syntax of any but the most common commands to make sure I get the parameters correct. Is your code working as you wish now? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now