A data control can only post edits to its associated dataset if the dataset's CanModify property is True. CanModify is always False for unidirectional datasets. Some datasets have a ReadOnly property that lets you specify whether CanModify is True.
Finally, you can control whether the user can even enter edits to the data that is displayed in the control. The ReadOnly property of the data control determines if a user can edit the data displayed by the control. If False (the default), users can edit data. Clearly, you will want to ensure that the control's ReadOnly property is True when the dataset's CanModify property is False. Otherwise, you give users the false impression that they can affect the data in the underlying database table.
In all data controls except TDBGrid, when you modify a field, the modification is copied to the underlying dataset when you Tab from the control. If you press Esc before you Tab from a field, the data control abandons the modifications, and the value of the field reverts to the value it held before any modifications were made.
In TDBGrid, modifications are posted when you move to a different record; you can press Esc in any record of a field before moving to another record to cancel all changes to the record.
When a record is posted, Delphi checks all data-aware controls associated with the dataset for a change in status. If there is a problem updating any fields that contain modified data, Delphi raises an exception, and no modifications are made to the record.
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|