<< Return to Main Index

< Return to Class Index

CGXBrowserGrid::Edit

virtual void Edit(ROWCOL nRow);

nRow

Specifies the row id.

Remarks

Call this member function to allow changes to the current record. After you call Edit, you can change the data of the current row by calling SetStyleRange. The operation is completed when you call the Update member function to save your changes on the data source.

Edit empties the current record buffer and resets all modified-bits. If you call Edit and make changes, these changes will be written to the current record buffer and a modified-bit is set. When calling Update, all modified columns are written to the data source.

When calling Edit, the grid displays a pencil in the row-header of the specified row indicating to the user that the row is changed.

Please note that if you call Edit again while there were pending changes, all pending changes will be canceled. You may also cancel pending changes in the record with UndoRecord.

See Also

CGXBrowserGrid::Update CGXBrowserGrid::UndoRecord

Example

The following sample code shows you how you can programmatically change a record to your data source.

   // Change the contents of nRow in the grid.
   if (CanUpdate())
   {
      // Enter edit-mode
      Edit(nRow);

      // Lock updating the grid
      BOOL bLock = LockUpdate(TRUE);

      SetValueRange(CGXRange(nRow, 1), "1");
      SetValueRange(CGXRange(nRow, 2), "2");

      // Unlock painting
      LockUpdate(bLock);

      // Flush pending changes, Update will also redraw
      // the row.
      Update();
   }

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 DAO recordset, ODBC recordset or any other external data source.

Remarks

Prepares for changes to the current record. Call Update to complete the edit.

CGXBrowserGrid

Class Overview | Class Members