Article ID: 141636
Article Last Modified on 9/30/2003
USE HOME()+"samples\data\customer.dbf" COPY TO cust_tmp.dbf
THIS.Drag(1) && Starts Drag
THIS.Drag(0) && Ends Drag if mouse button is released
LPARAMETERS oSource, nXCoord, nYCoord
PRIVATE nPrevColwidths, nGridLeftwall, nGridRightwall, nRowlevel, ;
nGridBottomEdge, nColCount
* Check destination grid for DeleteMark and RecordMark
nGridLeftWall=1+THIS.Left+IIF(THIS.DeleteMark and THIS.RecordMark,18, ;
IIF(THIS.DeleteMark or THIS.RecordMark,9,0))
* Check destination grid for Vertical Scroll bar
nGridRightWall=THIS.Left+THIS.Width-IIF(THIS.ScrollBars>1,14,0)
* Check destination grid for Horizontal Scroll bar
nGridBottomEdge=THIS.Top+THIS.Height-IIF(THIS.ScrollBars=1 or ;
THIS.ScrollBars=3, 12 ,0)
* Hold sum of ColumnWidths of columns to left of current column
nPrevColwidths=0
* Find out which destination row
nRowlevel=CEILING((nYcoord-THIS.Top-THIS.HeaderHeight)/THIS.RowHeight)
* Necessary if grid RecordSource table is not currently selected
SELECT EVAL('THIS.RecordSource')
* Loop through all visible columns
FOR ni=THIS.LeftColumn to THIS.ColumnCount
* Determine if current column is drop destination
IF BETWEEN(nXCoord, nGridLeftwall+nPrevColWidths, nGridLeftwall + ;
nPrevColwidths+THIS.Columns(ni).Width) and nRowlevel>0 and ;
nYCoord < nGridBottomEdge and nXCoord < nGridRightWall
* If correct column, call DragDrop of textbox in the column
THIS.Columns(ni).Text1.DragDrop(oSource,0,nYCoord, ;
ni+1-THIS.LeftColumn,nRowlevel)
EXIT && After drop, no need to check additional columns
ENDIF
* Add width of current column to sum of widths of previous columns
* and proceed to calculate if next column is drop destination
nPrevColWidths=nPrevColWidths+THIS.Columns(ni).Width
ENDFOR
LPARAMETERS oSource, nXCoord, nYCoord, nDropCol, nDropRow * Activate cell which is destination for drop THIS.PARENT.PARENT.ActivateCell(nDropRow,nDropCol) * Replace ControlSource field with value of dragged object REPLACE (THIS.ControlSource) WITH oSource.Value
Additional query words: VFoxWin
Keywords: kbcode KB141636