property Grid.DetectAddNew as Boolean
Specifies whether the control detects when a new record is added to the bounded recordset.

 TypeDescription 
   Boolean A boolean expression that indicates whether the control detects when a new record is added to the bounded recordset.  

The DetectAddNew property detects adding new records to a recordset. Use the DataSource property to bound the control to a table. If the DetectAddNew property is True, and user adds a new record to the bounded recordset, the control automatically adds a new item to the control. The DetectAddNew property has effect only if the control is bounded to an ADO, ADODB recordset, using the DataSource property.

The following VB sample adds new items when the AddNew method of the ADOR.Recordset is called:

Dim r As Object

Private Sub Command1_Click()
    r.AddNew
    r(0) = "new item"
    r(1) = "new subitem"
    r.Update
End Sub

Private Sub Form_Load()
    Set r = CreateObject("ADOR.Recordset")
    r.Fields.Append "Column 1", adBSTR
    r.Fields.Append "Column 2", adBSTR
    r.Open
    With Grid1
        .DetectAddNew = True
        Set .DataSource = r
    End With
End Sub

Send comments on this topic.
© 1999-2008 Exontrol Inc, Software. All rights reserved.