Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
This event fires when you click in the delete mark column in a grid.
PROCEDURE grdGrid.Deleted
LPARAMETERS nRecNo
The name Deleted is a little misleading, because the event fires whenever you click in the delete mark column, whether you’re deleting or recalling the record. The record number of the affected record is passed to nRecNo.
In VFP 6 and earlier, Help says Deleted fires when the DELETE command is used to delete a record, too. It's wrong. None of Xbase DELETE, DELETE-SQL or RECALL fire Deleted. Only clicks in the delete mark column do it. The Help bug is fixed in VFP 7, though the new text is a little ambiguous. |
Use NODEFAULT in the method to prevent the deletion or recall. Better yet, set DeleteMark to .F. and the user can’t delete records in the grid at all.
PROCEDURE Deleted
* Confirm the deletion.
LPARAMETERS nRecNo
LOCAL nResult
* In this example, the message uses the record number.
* In an application, you'd use data from the record.
nResult = MESSAGEBOX("Do you really want to delete record?" ;
+ LTRIM(STR(nRecNo)), MB_YESNO + MB_ICONQUESTION)
IF nResult = IDNO
NODEFAULT
ENDIF
ENDPROC