|| | |||Browse by category|
How can I programmatically append a record to the data source?
The following sample code shows you how you can programmatically append a record to your data source.
|// Append a row to the grid
|// Add a row
ROWCOL nAppendRow = AddNew();
ASSERT(nAppendRow != GX_INVALID);
// Lock updating the grid
// Change cells in new row
// Unlock painting
// Flush pending changes, Update will
Please note that this code depends only on CGXBrowserGrid-functionality and thus makes appending rows independent from your specific data source. You can use the same code for appending a row to a ADO recordset, ODBC recordset or any other external data source.
You have to change fields, so that the record will be set dirty. Otherwise, the call to Update() will undo the AddNew() command.
The following sample shows an alternative that allows you to add a record directly to a ADO recordset and bypass the grid. This should work similar for ODBC.
|AdoRecordset* prs = OnGetRecordset();
// Now, call OnAddedNewRecord so that the grid
// Scroll to the last row