This example extends Sorting List Views 1 by adding a second list view titled "SELECTLIST Employee Order" which is refilled every time a button titled "Show SELECTLIST Order" is clicked. It demonstrates that the order of the items in the list view remains constant (ie: in the order the items were added by the ADD_ENTRY command) regardless of how the user has sorted visual representation of the list
To see how the example works, copy this code and paste it to a form component:
FUNCTION options(*DIRECT)
BEGIN_COM role(*EXTENDS #PRIM_FORM) HEIGHT(594) LEFT(327) TOP(120) WIDTH(620)
DEFINE_COM class(#PRIM_LTVW) name(#EMPLIST) DISPLAYPOSITION(1) FULLROWSELECT(True) HEIGHT(221) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(1) TOP(28) WIDTH(577)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_1) DISPLAYPOSITION(1) PARENT(#EMPLIST) SORTONCLICK(True) SOURCE(#EMPNO) WIDTH(18)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_2) DISPLAYPOSITION(2) PARENT(#EMPLIST) SORTONCLICK(True) SOURCE(#SURNAME) WIDTH(23)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_3) DISPLAYPOSITION(3) PARENT(#EMPLIST) SORTONCLICK(True) SOURCE(#GIVENAME) WIDTH(25)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_4) DISPLAYPOSITION(4) PARENT(#EMPLIST) SORTONCLICK(True) SOURCE(#SALARY) WIDTH(16)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_5) DISPLAYPOSITION(5) PARENT(#EMPLIST) SORTONCLICK(True) SOURCE(#POSTCODE) WIDTH(18)
DEFINE_COM class(#PRIM_LTVW) name(#WRKLIST) DISPLAYPOSITION(2) FULLROWSELECT(True) HEIGHT(233) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(2) TOP(288) WIDTH(577)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_6) DISPLAYPOSITION(1) PARENT(#WRKLIST) SOURCE(#EMPNO) WIDTH(18)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_7) DISPLAYPOSITION(2) PARENT(#WRKLIST) SOURCE(#SURNAME) WIDTH(23)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_8) DISPLAYPOSITION(3) PARENT(#WRKLIST) SOURCE(#GIVENAME) WIDTH(25)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_9) DISPLAYPOSITION(4) PARENT(#WRKLIST) SOURCE(#SALARY) WIDTH(16)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_10) DISPLAYPOSITION(5) PARENT(#WRKLIST) SOURCE(#POSTCODE) WIDTH(18)
DEFINE_COM class(#PRIM_PHBN) name(#PB_ORDER) CAPTION('Show Selectlist Order') DISPLAYPOSITION(3) LEFT(472) PARENT(#COM_OWNER) TABPOSITION(3) TOP(528) WIDTH(112)
DEFINE_COM class(#PRIM_LABL) name(#LABL_1) CAPTION('SELECTLIST Employee Order') DISPLAYPOSITION(4) HEIGHT(25) LEFT(144) PARENT(#COM_OWNER) TABPOSITION(4) TABSTOP(False) TOP(528) VISUALSTYLE(#VS_LAREM) WIDTH(269)
EVTROUTINE handling(#com_owner.Initialize)
SELECT fields(#EMPLIST) from_file(PSLMST)
ADD_ENTRY to_list(#EMPLIST)
ENDSELECT
ENDROUTINE
EVTROUTINE handling(#PB_ORDER.Click)
CLR_LIST named(#WRKLIST)
SELECTLIST named(#EMPLIST)
ADD_ENTRY to_list(#WRKLIST)
ENDSELECT
ENDROUTINE
END_COM