/* HAUPTPROGRAMM */
Declare lever gb, btn1, btn2, btn3, btn4, btn5, btn6, Long end
Window 600, 400
btn1 = Create("Button", %HWnd, "ASC", 10, 10, 60, 25)
btn2 = Create("Button", %HWnd, "DESC", 10, 40, 60, 25)
btn3 = Create("Button", %HWnd, "ASC", 100, 10, 60, 25)
btn4 = Create("Button", %HWnd, "DESC", 100, 40, 60, 25)
btn5 = Create("Button", %HWnd, "ASC", 190, 10, 60, 25)
btn6 = Create("Button", %HWnd, "DESC", 190, 40, 60, 25)
gb = Create("Gridbox",%HWnd, "DATUM;0;80;MENGE;0;80;ARTIKEL;0;120", 0, 10, 70, 300, 150)
AddStrings(gb, "20.10.2015|500|Tomaten")
AddStrings(gb, "15.12.2017|200|Birnen")
AddStrings(gb, "22.11.2015|100|Ananas")
AddStrings(gb, "10.04.2016|50|Äpfel")
AddStrings(gb, "11.10.2017|1000|Zitronen")
AddStrings(gb, "01.04.2017|1500|Kirschen")
' SetHeader_SetArrow(gb, 0, 0)
end = 0
WhileNot end
WaitInput
If Clicked(btn1)
SortListview(gb, 0, 2, 0)
ElseIf Clicked(btn2)
SortListview(gb, 0, 2, 1)
ElseIf Clicked(btn3)
SortListview(gb, 1, 3, 0)
ElseIf Clicked(btn4)
SortListview(gb, 1, 3, 1)
Elseif Clicked(btn5)
SortListview(gb, 2, 1, 0)
ElseIf Clicked(btn6)
SortListview(gb, 2, 1, 1)
EndIf
Case %Key = 2 : end = 1
EndWhile
END
PROC SortListview
' ACHTUNG : uses The interne Listboxliste (Own data before with Move o.ä. secure)
' lv : lever the GridBOX
' slot : Nullbasierend (1. slot = 0)
' SortType : Spalteninhalt (1 = STRINGS, 2 = DATUM (tt.mm.jjjj), 3 = ZAHLEN)
' order : 0 = ascending, 1 = absteigend
Parameters lever lv, Long slot, SortType, order
DECLARE lever list, LONG sOrder, sTyp, STRING item, row, Float date
list = Create("List", 0)
SELECT SortType
CASEOF 1
sTyp = 4' properly Gebietsschema
CASEOF 2
sTyp = 5
CASEOF 3
sTyp = 5
ENDSELECT
Select order
CaseOf 0
sOrder = 1
CASEOF 1
sOrder = -1
ENDSELECT
IF SortType = 2' DATUM - SORTIERUNG
CLEARLIST 0
MOVE("HandleToList", lv)
WHILELOOP 0, GETCOUNT(0) -1
item = SubStr$(GetSTRING$(0, &LOOP), slot + 1, "|")
date = Str $(DT("SetDate", item))
row = Translate$(GetString$(0, &LOOP), item, Str $(date))
AddStrings(list, row)
ENDWHILE
CLEARLIST 0
MOVE("HandleToList", list)
SortList "|", slot + 1, (sTyp * sOrder)
CLEARLIST list
MOVE("ListToHandle", list)
CLEARLIST 0
WHILELOOP 0, GETCOUNT(list) - 1
item = SubStr$(GetString$(list, &LOOP), slot + 1, "|")
row = Translate$(GetString$(list, &LOOP), item, DT("GetDate", 0, VAL(item)))
AddStrings(0, row)
ENDWHILE
ELSE
CLEARLIST 0
MOVE("HandleToList", lv)
SortList "|", slot + 1, (sTyp * sOrder)
ENDIF
CLEARLIST lv
MOVE("ListToHandle", lv)
CLEARLIST 0
ENDPROC