BUG: Deleted Event Does Not Fire When Deleting Programmatically (191641)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0b
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 5.0a
  • Microsoft Visual FoxPro for Windows 6.0

This article was previously published under Q191641

SYMPTOMS

A grid's Deleted event does not fire when a record is programmatically deleted. However, the event does fire if you interactively delete a record in a grid.

RESOLUTION

Call the grid's Deleted event explicitly using code. For the sample code in the MORE INFORMATION section, see step 3 for further instructions.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a program (.prg) file that contains the following code and run the program:
          CREATE TABLE Ztest (A c(1), B c(1))
          INSERT INTO Ztest (A,B) VALUES ('A', 'B')
    
          USE 'Ztest'
    
          F1 = CREATE('oForm')
          F1.SHOW
          * F1.gridcontrol.Deleted  && Remove comment to see grid's Deleted
                                    && event fire.
          READ EVENTS
    
          DEFINE CLASS oForm AS FORM
             ADD OBJECT GRIDcontrol AS myGRID
             PROC INIT
                DELETE
             PROC DESTROY
                CLEAR EVENTS
          ENDDEFINE
    
          DEFINE CLASS myGRID AS GRID
             RECORDSOURCE='Ztest'
             RECORDSOURCETYPE=1
             PROC DELETED
                LPARAMETERS nRecNo
                WAIT WIND "Deleted Event Fired"
          ENDDEFINE
    							
  2. Notice that the record is marked as deleted in the grid, but the grid's Deleted event never fired. Now, double-click the deletion marker in the grid (the black rectangle to left of the first field in the grid) and note that the grid's deleted event fires as expected.
  3. Remove the asterisk from the commented line of code in the example so that is reads as follows:
          F1.gridcontrol.Deleted
    							
    Run the example again. Note that the grid's Deleted event fires when explicitly called with code.

Modification Type:MajorLast Reviewed:5/12/2003
Keywords:kbbug kbcode kbnofix KB191641