Unbound Mode > Unbound Mode Events > Handling the UnboundAddData event in modes 1 and 2 |
This event applies to both DataMode 1 - Unbound and 2 - Unbound Extended.
If the AllowAddNew and AllowUpdate properties of the grid are True, then users can add new records to the grid, and you must implement the UnboundAddData event. The syntax of this event is as follows:
Example Title |
Copy Code
|
---|---|
Private Sub TDBGrid1_UnboundAddData( _ ByVal RowBuf As RowBuffer, NewRowBookmark As Variant) |
As with the UnboundWriteData event, data from the new row is passed via a RowBuffer object. When this event is fired, the properties of the RowBuf argument are set as follows:
RowCount is 1, since only one row can be added at a time.
ColumnCount specifies the number of columns of data in the Value array.
The Bookmark array is not used, since the new row does not yet have a valid bookmark.
The Value array contains a single row of data. Entries which are Null have not been specified by the user. Entries which are not Null reflect the user's additions.
The NewRowBookmark argument is initially Null. However, before returning from this event, you must set it to a bookmark that uniquely identifies the newly added row. If you do not set the value of NewRowBookmark, the add operation will fail and the grid will not allow its current row to change.