Reinhardt1julian Posted February 14, 2013 Share Posted February 14, 2013 How can i Sort the listviewitems alphabetically? Like in the Explorer, on a click on a collumn, this column gets sortet from A-Z, when you click another time this column gets sortet from Z-A Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Reinhardt1julian,Search for "listview sort" in the Help file and _GUICtrlListView_SimpleSort would jump out as a candidate. M23 Burgaud 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...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 (edited) But how can i say on click on column 1 _GUICtrlListView_SimpleSort($ListView, True, 1) and on click on column 2 _GUICtrlListView_SimpleSort($ListView, True, 2) Either i'm blind or its not in the helpfile. Edited February 14, 2013 by Reinhardt1julian Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Reinhardt1julian, It is one of the more confusing functions - does this help to explain it better? #include <GUIConstantsEx.au3> #include <GUIListView.au3> ; This array retains the sort state of each column Global $aSorting[2] $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Col 0|Col 1", 10, 10, 200, 300, Default, $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetColumnWidth($cLV, 0, 100) _GUICtrlListView_SetColumnWidth($cLV, 1, $LVSCW_AUTOSIZE_USEHEADER) For $i = 1 To 14 $sCol1 = Chr(Random(65, 90, 1)) $sCol2 = Chr(Random(65, 90, 1)) GUICtrlCreateListViewItem($sCol1 & "|" & $sCol2, $cLV) Next $cButton_0 = GUICtrlCreateButton("Sort Col 0", 10, 320, 80, 30) $cButton_1 = GUICtrlCreateButton("Sort Col 1", 100, 320, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_0 ; We pass the array to the function each time so it know what state it needs to provide _GUICtrlListView_SimpleSort($cLV, $aSorting, 0) Case $cButton_1 _GUICtrlListView_SimpleSort($cLV, $aSorting, 1) EndSwitch WEnd 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...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 (edited) I dont get this part: For $i = 1 To 14 $sCol1 = Chr(Random(65, 90, 1)) $sCol2 = Chr(Random(65, 90, 1)) GUICtrlCreateListViewItem($sCol1 & "|" & $sCol2, $cLV) Next What does it do? Edited February 14, 2013 by Reinhardt1julian Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Reinhardt1julian,What does it do to the ListView? What do the individual functions within those lines do? Read the Help file for Chr and Random and look at the ASCII table in the Appendix - see if you can work it out for yourself. If you cannot after a reasonable time (say 30 mins) ask again. 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...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 Ohh, it gives out random letters, right? But can you make the Top of the list view buttons? That were in your script "col 1" or "Col 0" is, that this is a button? Link to comment Share on other sites More sharing options...
PhoenixXL Posted February 14, 2013 Share Posted February 14, 2013 If you want that way you should look at the example of GUICtrlRegisterListViewSort My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 (edited) How can is say that 1 column should always be sorted from A-Z? I Can't figure it out. Just "True" wont work. And i don#t find anything in the help file, that could help me. Edited February 14, 2013 by Reinhardt1julian Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 PhoenixXL,No need to go that far - you can still use the SimpleSort function as long as you do not want the little arrows on the headers:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> ; This array retains the sort state of each column Global $aSorting[2] $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Col 0|Col 1", 10, 10, 200, 300, Default, $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetColumnWidth($cLV, 0, 100) _GUICtrlListView_SetColumnWidth($cLV, 1, $LVSCW_AUTOSIZE_USEHEADER) For $i = 1 To 14 $sCol1 = Chr(Random(65, 90, 1)) $sCol2 = Chr(Random(65, 90, 1)) GUICtrlCreateListViewItem($sCol1 & "|" & $sCol2, $cLV) Next GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $iIDFrom Case $cLV Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) _GUICtrlListView_SimpleSort($cLV, $aSorting, DllStructGetData($tInfo, "SubItem")) EndSwitch EndSwitch EndFuncReinhardt1julian,I think this script is a bit advanced for you at the moment - but see if you can follow it. The GUIRegisterMsg tutorial in the Wiki might be helpful. M23Edit:Just seen your next question. Just call the SimpleSort function from within your script:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> ; This array retains the sort state of each column Global $aSorting[2] $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Col 0|Col 1", 10, 10, 200, 300, Default, $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetColumnWidth($cLV, 0, 100) _GUICtrlListView_SetColumnWidth($cLV, 1, $LVSCW_AUTOSIZE_USEHEADER) For $i = 1 To 14 $sCol1 = Chr(Random(65, 90, 1)) $sCol2 = Chr(Random(65, 90, 1)) GUICtrlCreateListViewItem($sCol1 & "|" & $sCol2, $cLV) Next GUISetState() ; Always have the first column sorted _GUICtrlListView_SimpleSort($cLV, $aSorting, 0) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndAll clear? 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...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 Yes, it is a bit too advanced. But i always want column 1 to be sorted from A-Z. But with the $ASort it changes everytime the script is called. But i want it just to sort every item in column 1 to sort from A-Z. But just Putting "true" in the _GUICtrlListView_SimpleSort won't work. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Reinhardt1julian,But with the $ASort it changes everytime the script is calledNo it does not. Are you creating the ListView and running the sort in a function? 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...
PhoenixXL Posted February 14, 2013 Share Posted February 14, 2013 For A-Z I guess it is Ascending Hence you should use False My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 I call it after a function. But in my script it changes everytime the sort function is called Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 PhoenixXL,The parameter is passed ByRef - so it must be a predeclared variable or array and cannot be a straight Boolean. 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...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Reinhardt1julian, Then set the sort variable each time you call the function like this: #include <GUIConstantsEx.au3> #include <GUIListView.au3> ; This array retains the sort state of each column Global $aSorting[2] _ListView() Func _ListView() $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Col 0|Col 1", 10, 10, 200, 300, Default, $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetColumnWidth($cLV, 0, 100) _GUICtrlListView_SetColumnWidth($cLV, 1, $LVSCW_AUTOSIZE_USEHEADER) For $i = 1 To 14 $sCol1 = Chr(Random(65, 90, 1)) $sCol2 = Chr(Random(65, 90, 1)) GUICtrlCreateListViewItem($sCol1 & "|" & $sCol2, $cLV) Next GUISetState() ; Set the sort like this - then the next sort will always be A-Z $fSort = False _GUICtrlListView_SimpleSort($cLV, $fSort, 0) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc Better? 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...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 (edited) It toggles everytime Even if i remove the arguments from $aSorting and set it fo false... EDIT: Ok, I'll try it as a non-Global variable... And that works Edited February 14, 2013 by Reinhardt1julian Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Reinhardt1julian, Then post the code you are using because you must be doing something else in the script to cause it - the code I have posted so far does not exhibit that behaviour when run. 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...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 It seemed to be the problem, that i declared the variable as global. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Reinhardt1julian,That is the second time you tell us that changing the scope of a variable has solved your problem. Are you sure that you understand variable scope in AutoIt? Did you read, and understand, the tutorial to which I linked you earlier today? 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