表格与表格见能实现记录拖动吗
在一个表单中,如何实现两个表格间记录直接拖动
CLEAR ALL CLOSE DATABASES ALL SET DEFAULT TO (Application.ActiveProject.HomeDir) Form1 = NEWOBJECT("C_Form") Form1.Show READ EVENTS CLOSE DATABASES ALL CLEAR ALL RETURN DEFINE CLASS C_Form AS Form Caption = "拖拉数据测试程序" WindowState = 2 DIMENSION aRecord[1] ADD OBJECT Grid1 AS Grid ADD OBJECT Grid2 AS Grid PROCEDURE Load USE Table1 IN 0 USE Table2 IN 0 ENDPROC PROCEDURE Unload USE IN Table1 USE IN Table2 ENDPROC PROCEDURE Destroy CLEAR EVENTS ENDPROC PROCEDURE Activate ThisForm.Arrange ENDPROC PROCEDURE Resize ThisForm.Arrange ENDPROC PROCEDURE Arrange WITH This.Grid1 .Top = 5 .Left = 5 .Width = (ThisForm.Width / 2 - 10) - .Left .Height = ThisForm.Height - .Top - 5 ENDWITH WITH This.Grid2 .Top = 5 .Left = This.Grid1.Left + This.Grid1.Width .Width = This.Width - .Left - 5 .Height = This.Height - .Top - 5 ENDWITH ENDPROC PROCEDURE Grid1.Init WITH This .RecordSourceType = 1 .RecordSource = "Table1" BINDEVENT(.Columns(1).Text1, "MouseDown", This, "MouseDown") ENDWITH ENDPROC PROCEDURE Grid1.MouseDown(tnButton, tnShift, tnXCoord, tnYCoord) DODEFAULT() IF tnButton == 2 && 单击鼠标右键激活拖放 ThisForm.Get_Record("Table1") LOCAL laArray[1] AMOUSEOBJ(laArray) && 获取鼠标下面的对象 laArray[1].Drag && 启动拖放 ENDIF ENDPROC PROCEDURE Grid1.DragDrop(toSource, tnXCoord, tnYCoord) LOCAL lnRow, lnCol WITH This .GridHitTest(tnXCoord, tnYCoord, 3, @lnRow, @lnCol) .ActivateCell(lnRow, lnCol) ThisForm.Put_Record("Table1") .SetFocus ENDWITH ENDPROC PROCEDURE Grid2.Init WITH This .RecordSourceType = 1 .RecordSource = "Table2" BINDEVENT(.Columns(1).Text1, "MouseDown", This, "MouseDown") ENDWITH ENDPROC PROCEDURE Grid2.MouseDown(tnButton, tnShift, tnXCoord, tnYCoord) DODEFAULT() IF tnButton == 2 && 单击鼠标右键激活拖放 ThisForm.Get_Record("Table2") LOCAL laArray[1] AMOUSEOBJ(laArray) && 获取鼠标下面的对象 laArray[1].Drag && 启动拖放 ENDIF ENDPROC PROCEDURE Grid2.DragDrop(toSource, tnXCoord, tnYCoord) LOCAL lnRow, lnCol WITH This .GridHitTest(tnXCoord, tnYCoord, 3, @lnRow, @lnCol) .ActivateCell(lnRow, lnCol) ThisForm.Put_Record("Table2") .SetFocus ENDWITH ENDPROC *-------------------- * 获取源记录 *-------------------- PROCEDURE Get_Record(tcAlias) DIMENSION ThisForm.aRecord[FCOUNT(tcAlias)] SELECT (tcAlias) SCATTER TO ThisForm.aRecord ENDPROC *-------------------- * 放入记录 *-------------------- PROCEDURE Put_Record(tcAlias) SELECT (tcAlias) GATHER FROM ThisForm.aRecord ENDPROC ENDDEFINE