Jump to content

Recommended Posts

  • Moderators
Posted

Reinhardt1julian,

Search for "listview sort" in the Help file and _GUICtrlListView_SimpleSort would jump out as a candidate. ;)

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

 

Posted (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 by Reinhardt1julian
  • Moderators
Posted

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

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

 

  • Moderators
Posted

Reinhardt1julian,

What does it do to the ListView? What do the individual functions within those lines do? :huh:

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

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

 

Posted

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.

Posted (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 by Reinhardt1julian
  • Moderators
Posted

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:

#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

EndFunc

Reinhardt1julian,

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

M23

Edit:

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
WEnd

All clear? :)

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

 

Posted

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.

  • Moderators
Posted

Reinhardt1julian,

But with the $ASort it changes everytime the script is called

No it does not. Are you creating the ListView and running the sort in a function? :huh:

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

 

Posted

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.

  • Moderators
Posted

PhoenixXL,

The parameter is passed ByRef - so it must be a predeclared variable or array and cannot be a straight Boolean. ;)

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

 

  • Moderators
Posted

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

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

 

Posted (edited)

It toggles everytime :huh: 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 :D

Edited by Reinhardt1julian
  • Moderators
Posted

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

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

 

  • Moderators
Posted

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? :huh:

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

 

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
  • Recently Browsing   0 members

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