Source Code for List Collection Example 1
Source for the first form
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(319) Clientwidth(247) Dragstyle(Automatic) Height(346) Left(255) Top(111) Width(255)
* The Drag List Definition. Note the use of the DragStyle(Automatic) property
Define_Com Class(#PRIM_LTVW) Name(#DRAG_LIST) Displayposition(1) Dragstyle(Automatic) Fullrowselect(True) Height(285) Left(8) Parent(#COM_OWNER) Tabposition(1) Top(8) Width(217)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_1) Displayposition(1) Parent(#DRAG_LIST) Source(#EMPNO) Width(53)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_2) Displayposition(2) Parent(#DRAG_LIST) Source(#SALARY) Width(45) Widthtype(Remainder)
* Define the drop form (change this name to the name you give to the second form)
Define_Com Class(#LCOL00004)
* ===============================
* Handle main form initialization
* ===============================
Evtroutine Handling(#com_owner.Initialize)
* Fill the drag list with employee details
Select Fields(#DRAG_LIST) From_File(PSLMST)
Add_Entry To_List(#DRAG_LIST)
Endselect
* Show the drop list form (change #LCOL00004 to the name you give to the second form)
Invoke Method(#LCOL00004.ShowForm)
Endroutine
* ==================================
* Handle starting the drag operation
* ==================================
Evtroutine Handling(#Drag_List.StartDrag) Draglist(#DragList) Continue(#Continue) Payload(#PayLoad)
Define_Com Class(#Prim_LCOL<#Prim_ALPH>) Name(#PayLoadList) Reference(*Dynamic)
Define_Com Class(#Prim_ALPH) Name(#EmployeeNumber) Reference(*Dynamic)
* Dynamically create the list collection that is to to be the "payload"
* for this drag operation
Set_Ref Com(#PayLoadList) To(*Create_as #Prim_LCOL<#Prim_ALPH>)
* Now fill the list collection with the employee numbers of all
* the currently selected employees
Selectlist Named(#DRAG_LIST)
Continue If('#Drag_List.Currentitem.Selected *ne True')
Set_Ref Com(#EmployeeNumber) To(*Create_as #Prim_ALPH)
Set Com(#EmployeeNumber) Value(#EmpNo)
Invoke Method(#PayLoadList.Insert) Item(#EmployeeNumber)
Endselect
* Finished
Set Com(#Continue) Value(True)
Set_Ref Com(#PayLoad) To(#PayLoadList)
Set Com(#DragList) Dragliststyle(Selection)
Endroutine
End_Com
Source for the second form
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(310) Clientwidth(137) Dragstyle(Automatic) Formstyle(StayOnTopChild) Height(337) Left(577) Top(120) Width(145)
* The Drop List Definition
Define_Com Class(#PRIM_LTVW) Name(#DROP_LIST) Displayposition(1) Fullrowselect(True) Height(285) Left(16) Parent(#COM_OWNER) Tabposition(1) Top(8) Width(105)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_1) Displayposition(1) Parent(#DROP_LIST) Source(#EMPNO) Width(53) Widthtype(Remainder)
* ===============================
* Handle Drag Over the drop list
* ===============================
Evtroutine Handling(#Drop_List.DragOver) Acceptdrop(#AcceptDrop) Payload(#PayLoad)
* If the payload to be dropped is a list collection of alphas
* accept it otherwise reject it .....
If_Ref Com(#PayLoad) Is(*Instance_of #Prim_LCol<#Prim_alph>)
Set Com(#AcceptDrop) Value(True)
Else
Set Com(#AcceptDrop) Value(False)
Endif
Endroutine
* =========================================
* Handle the actual drop into the drop list
* =========================================
Evtroutine Handling(#Drop_List.DragDrop) Payload(#PayLoad)
Define_Com Class(#Prim_LCOL<#Prim_ALPH>) Name(#PayLoadList) Reference(*Dynamic)
* Cast the payload as a list colelction of alphas ....
Set_Ref Com(#PayLoadList) To(*Dynamic #PayLoad)
* Clear the drop list and fill it will all the employee numbers in the payload ...
Clr_List Named(#DROP_LIST)
For Each(#EmployeeNumber) In(#PayLoadList)
Change Field(#EMPNO) To('#EMPLOYEENUMBER.VALUE')
Add_Entry To_List(#DROP_LIST)
Endfor
Endroutine
End_Com