Already done:
To click on a column header toggles the sorting of a column "up / down" (asc. / desc.).
With "Colclick" I can remember the number of the sorted column.
Question:
How to recognize, store and reuse if the column was sorted "up or down"?
Is there a built in feature or must it be handled with subroutines, counters and so on?
Peter
ListView - ColClick: Sort up / sort down
ListView - ColClick: Sort up / sort down
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
-
- Posts: 319
- Joined: 23 Jan 2016, 23:03
Re: ListView - ColClick: Sort up / sort down
Code: Select all
gui, Add, ListView, gLVClick, A|B|C
LV_Add("", 1, 2, 3)
LV_Add("", 4, 5, 6)
LV_Add("", 7, 8, 9)
gui, Show
return
LVClick:
if(A_GuiEvent = "ColClick") {
LV_GetText(Out1, 1, A_EventInfo)
LV_GetText(Out2, 2, A_EventInfo)
isSortedDown:=Out2 > Out1
MsgBox % isSortedDown ? "Sorted down!" : "Sorted Up!"
}
Re: ListView - ColClick: Sort up / sort down
Thanks - fine and compact!
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
-
- Posts: 319
- Joined: 23 Jan 2016, 23:03
Re: ListView - ColClick: Sort up / sort down
Of course there is a flaw if you have the same value...
Code: Select all
gui, Add, ListView, gLVClick, A|B|C
LV_Add("", 1, 2, 3)
LV_Add("", 1, 8, 6)
LV_Add("", 7, 8, 9)
gui, Show
return
LVClick:
if(A_GuiEvent = "ColClick") {
LV_GetText(Out1, 1, A_EventInfo)
LV_GetText(Out2, 2, A_EventInfo)
while(Out1 = Out2)
LV_GetText(Out2, A_Index + 2, A_EventInfo)
isSortedDown:=Out2 > Out1
MsgBox % isSortedDown ? "Sorted down!" : "Sorted Up!"
}
Re: ListView - ColClick: Sort up / sort down
I modified it to check first against last value, and change the operator:
Code: Select all
LV_GetText(Out1, 1, A_EventInfo)
LV_GetText(Out2, LV_GetCount(), A_EventInfo)
isSortedDown := Out2 < Out1
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
-
- Posts: 319
- Joined: 23 Jan 2016, 23:03
Who is online
Users browsing this forum: mikeyww and 130 guests