GridHitTest
This is a very cool method, added in VFP 6. It lets you figure out where you are in a grid. It is a little strange to use, though, because unlike any other method we can think of, it expects some parameters to be passed by reference. Usage | lInGrid = grdGrid.GridHitTest( nXCoord, nYCoord [, @nGridComponent [, @nRelativeRow [, @nRelativeColumn [, @nGridPane ] ] ] ] ) |
Parameter | Value | Meaning |
nXCoord, nYCoord | Numeric | The point to check to determine whether it's in the grid. |
nGridComponent | Numeric | If the point is in the grid, receives a value indicating which part of the grid that point is in. Otherwise, receives 0. |
nRelativeRow | Numeric | If the point is in the grid, receives the relative row in the grid where the point is found. |
nRelativeColumn | Numeric | If the point is in the grid, receives the relative column in the grid where the point is found. |
nGridPane | Numeric | If the point is in the grid, receives the pane of the grid where the point is found. |
lInGrid | .T. | The point is in the grid. "In the grid" includes everything up to the very outside border of the grid. |
.F. | The point is not in the grid. |
Example | * Code for grid's DragDrop event to put data into cell * There are some assumptions here, including that the control * of interest is the second one. (The first is always the * header.) More code could get rid of that assumption. LPARAMETERS oSource, nXCoord, nYCoord cData = oSource.Value LOCAL nComp, nRow, nCol IF This.GridHitTest(nXCoord,nYCoord,@nComp,@nRow,@nCol) IF nComp = 3 This.SetFocus() This.ActivateCell(nRow,nCol) This.Columns[This.ActiveColumn].Controls[2].Value = cData ENDIF ENDIF |
See Also | ActivateCell, DragDrop, Grid, MCol(), MRow(), OLEDragDrop |
View Updates
Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.