Version

About the DataValueChanged Event

You can track the changes made to the cell values in a field by setting a FieldSettings object’s DataValueChangedNotificationsActive property to True. When you enable this feature on a field, the DataPresenter controls will raise the DataValueChanged event and the InitializeCellValuePresenter events for the cells in that field.

The DataValueChanged Event

A DataPresenter control will raise the DataValueChanged event under the following circumstances:

  1. You are tracking data-value changes on a Field object by setting its FieldSettings object’s DataValueChangedNotificationsActive property to True.

  2. A cell’s value changes in the field that is tracking data value changes.

  3. The DataPresenter control has allocated a DataRecord object for the cell whose value has changed. If you want a DataPresenter control to raise the DataValueChanged event even if it has not allocated a DataRecord object, you must set its RecordLoadMode property to PreloadRecords and set the FieldSettings object’s DataValueChangedScope property to AllAllocatedRecords.

The DataPresenter controls pass in a DataValueChangedEventArgs object to the DataValueChanged event handler. You can use the properties exposed by the DataValueChangedEventArgs object to highlight a cell when its value changes. The DataValueChangedEventArgs object exposes the following properties:

  • CellValuePresenter - This property gives you a reference to the CellValuePresenter object that is used to display the cell’s value. This property may return NULL if the cell is not in view and the DataRecord object for the cell has not been allocated.

  • ValueHistory - This property is a list of data-value changes where the most recent change is stored in the 0th index. By default, the number of data value changes is set to 1. However, you can modify the number of changes kept in a cell’s data-value history by setting a FieldSettings object’s DataValueChangedHistoryLimit property. If you set the DataValueChangedHistoryLimit property to 0, the ValueHistory property will be NULL.

  • Field - The Field object that the cell belongs to.

  • Record – The DataRecord object that the cell belongs to.

The InitializeCellValuePresenter Event

When you enable data-value change tracking for a field, a DataPresenter control will fire the InitializeCellValuePresenter event when it attaches a CellValuePresenter object to a cell in that field. You can use the InitializeCellValuePresenterEventArgs object’s IsNew property to determine if the CellValuePresenter is a new or recycle instance a CellValuePresenter object.

Performance Implications

You should only track data value changes on fields that require tracking. Enabling this feature on all fields in a DataPresenter control and keeping too many changes in the cell’s data-value history may adversely affect your application’s performance.