property Grid.DetectDelete as Boolean
Specifies whether the control detects when a record is deleted from the bounded recordset.

TypeDescription
Boolean A boolean expression that indicates whether the control detects when a record is deleted from the bounded recordset.

By default, the DetectDelete property is False. If the DetectDelete property is True, the control is notified when a record is deleted, and the associated item is removed from the control's items collection ( valid for the ADO, ADODB recordsets ). The /COM version of the component provides the DataSource property, which can be used to bound the control's view to a DAO recordset. By default, once you set the DataSource property to a recordset, all changes you do on the control will be updated in the associated recordset. Because the DAO object does not provide any notifications or events the control is not able to detect any AddNew or Delete method that has been called. Instead, the control provides the AddItem and RemoveItem events that notifies your application once a new item is added to the control, or when an item is deleted. Based on these events, you will be able to manipulate the DAO recordset appropriate as in the following samples. In addition, the control fires the Error event in case any error occurs when handling the ADO or DAO recordsets, For instance, trying to update a read-only field.  In conclusion, if user changes a cell/value in the control, the associated field in the recordset is automatically updated. If any error occurs on updating the associated record, the Error event is fired which describes the error.

Handling the Delete method in the control, using the DAO recordset on MS Access

The code binds the control to a DAO recordset. The DetectDelete property on True, makes the control to move the current record on the item to be deleted, and to remove any reference to the record to be deleted.

Private Sub cmdRemove_Click()
    With Grid1.Items
        .RemoveItem .FocusItem
    End With
End Sub

The code removes the focused item. The Items.RemoveItem call makes the control to fire the RemoveItem event, which will actually delete the associated record in the database, as in the following code

The code deletes the current record.

Handling the Delete method in the control, using the ADO recordset in VB

The code binds the control to an ADO recordset.

Private Sub cmdRemove_Click()
    With Grid1.DataSource
        .Delete
    End With
End Sub

The Delete method of the recordset removes the current record ( select a new item to the control, and the current record is changed ), and due DetectDelete the associated item is removed from the view.