Page History
&<img src="../resources/images/opentocr.png" title="Open Contents list" border="0"&>
You are here:
...
This example is otherwise the same as the List Collection Example 1 except that the drag and drop operation involves more employee details and these details are stored in an employee object:
The Employee Object
The employee object is used to store employee details. This object is then used in the collection for the drag and drop operation.
The object defines and publishes these employee properties:
...
- ----------------------------
- This is an "Employee" object
- ----------------------------
- Define the member variables that define an "Employee" object ....
Define_Com Class(#Empno)
Define_Com Class(#GiveName)
Define_Com Class(#SurName)
Define_Com Class(#Deptment)
Define_Com Class(#Salary)
Define_Com Class(#PostCode) - Publish the properties that an "Employee" exposes .....
Define_Pty Name(pEmpno) Get(*Auto #Empno) Set(*Auto #Empno)
Define_Pty Name(pGiveName) Get(*Auto #GiveName) Set(*Auto #GiveName)
Define_Pty Name(pSurName) Get(*Auto #SurName) Set(*Auto #SurName)
Define_Pty Name(pDepartment) Get(*Auto #Deptment) Set(*Auto #Deptment)
Define_Pty Name(pSalary) Get(*Auto #Salary) Set(*Auto #Salary)
Define_Pty Name(pPostCode) Get(*Auto #PostCode) Set(*Auto #PostCode)
End_Com
First Form
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(319) Clientwidth(509) Dragstyle(Automatic) Height(346) Left(255) Top(111) Width(517) - 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(465)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_1) Displayposition(1) Parent(#DRAG_LIST) Source(#EMPNO) Width(18)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_2) Displayposition(2) Parent(#DRAG_LIST) Source(#SALARY) Width(20)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_3) Displayposition(3) Parent(#DRAG_LIST) Source(#SURNAME) Width(20)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_4) Displayposition(4) Parent(#DRAG_LIST) Source(#GIVENAME) Width(20)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_5) Displayposition(5) Parent(#DRAG_LIST) Source(#DEPTMENT) Width(11)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_6) Displayposition(6) Parent(#DRAG_LIST) Source(#POSTCODE) Width(20) Widthtype(Remainder) - Define the drop form (change #LCOL00004 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<#Employee>) Name(#PayLoadList) Reference(*Dynamic)
Define_Com Class(#Employee) Name(#DragEmployee) Reference(*Dynamic) - Dynamically create the list collection that is to to be the "payload"
- for this drag operation. It is a list collection of #Employee objects
Set_Ref Com(#PayLoadList) To(*Create_as #Prim_LCOL<#Employee>) - Now fill the list collection with the employees that are selected
Selectlist Named(#DRAG_LIST)
Continue If('#Drag_List.Currentitem.Selected *ne True')
Set_Ref Com(#DragEmployee) To(*Create_as #Employee)
Set Com(#DragEmployee) Pempno(#Empno) Pgivename(#GiveName) Psurname(#Surname) Psalary(#Salary) Pdepartment(#Deptment) Ppostcode(#PostCode)
Invoke Method(#PayLoadList.Insert) Item(#DragEmployee)
Endselect - Finished. Set the correct return values
Set Com(#Continue) Value(True)
Set_Ref Com(#PayLoad) To(#PayLoadList)
Set Com(#DragList) Dragliststyle(Selection)
Endroutine
End_Com
Second Form
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(433) Clientwidth(331) Dragstyle(Automatic) Formstyle(StayOnTopChild) Height(460) Left(453) Top(49) Width(339) - The Drop List Definition
Define_Com Class(#PRIM_LTVW) Name(#DROP_LIST) Displayposition(1) Dragstyle(Automatic) Fullrowselect(True) Height(418) Left(6) Parent(#COM_OWNER) Tabposition(1) Top(7) Width(321)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_1) Displayposition(1) Parent(#DROP_LIST) Source(#EMPNO) Width(18)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_3) Displayposition(2) Parent(#DROP_LIST) Source(#SURNAME) Width(20)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_4) Displayposition(3) Parent(#DROP_LIST) Source(#GIVENAME) Width(40)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_6) Displayposition(4) Parent(#DROP_LIST) Source(#POSTCODE) Width(20) 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 employees
- then accept it otherwise reject it .....
If_Ref Com(#PayLoad) Is(*Instance_of #Prim_LCol<#Employee>)
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<#Employee>) Name(#EmployeePayLoad) Reference(*Dynamic) - Cast the payload as a list collection of employee objects ....
Set_Ref Com(#EmployeePayLoad) To(*Dynamic #PayLoad) - Fill drop list with all the employee numbers in the payload ...
Clr_List Named(#DROP_LIST)
For Each(#EmployeeObject) In(#EmployeePayLoad)
Change Field(#EMPNO) To('#EMPLOYEEOBJECT.PEMPNO')
Change Field(#GIVENAME) To('#EMPLOYEEOBJECT.PGIVENAME')
Change Field(#SURNAME) To('#EMPLOYEEOBJECT.PSURNAME')
Change Field(#POSTCODE) To('#EMPLOYEEOBJECT.PPOSTCODE')
Add_Entry To_List(#DROP_LIST)
Endfor
Endroutine
End_Com
&<img src="../resources/images/opentoc-dark.png" title="Open Contents List" border="0"&>