ComponentOne True DataControl 8.0
Field Modification Modes

One of the advantages of True DataControl over the standard ADO data control and other data sources is that True DataControl can react instantly to field value modifications initiated by the user.

Often, your application needs to perform a specific action in response to a field modification. Other fields may depend on the modified value, or you may need to verify that the modified value satisfies certain constraints. For example, when a check box is toggled, it is usually necessary to update the recordset field to which it is bound. Visual Basic does not provide this functionality. Without True DataControl, you would have to write code to handle an appropriate event in the control that initiated the change. In the case of a check box, it would be its Click event. Moreover, there is no standard way in Visual Basic code to update the recordset fields with modified values from bound controls. You can only write code that directly sets the recordset field value in the check box’s Click event, but that defeats the purpose of data binding. What have we gained from binding a check box to a field if we have to write code directly updating the field when the check box value is changed?

True DataControl solves this problem, complements of the Visual Basic environment, with well-defined field modification functionality. This frees you from the tedious task of coding event handlers, effectively widening the scope of Visual Basic data binding.

This functionality is unavailable in the Lite version.

With True DataControl, you do not need to write control-specific event handlers. Just set the field’s ModificationMode property to either1 - Immediate or 2 - Leaving control (the default). Provided that ModificationMode is not 0 - None, True DataControl will react to field modifications (both by the end-user and from code), and perform whatever actions are necessary, such as re-evaluating all expressions that depend on the changed value. True DataControl will also propagate the changes to any dependent fields or control properties, and will even refresh dependent TData controls if necessary.

Note: It is important to understand that "reacting to a field change" only means that True DataControl stores updated field values in its recordset, as in an internal buffer; it does not yet post changes to the database. Changes are posted to the database whenever the TData control is repositioned to another record, or when your code explicitly calls the Recordset.Update method.

The allowable settings for the ModificationMode property are as follows:

1 - Immediate

Suitable for a field represented by controls such as list box, dropdown-list combo box, check box, radio button, or any other control whose value can be changed by a single click or keystroke. Such fields are updated immediately when the user interacts with the control to change the field’s value.

2 - Leaving control

This is the default setting, which is typically used with data entry controls that accept keyboard input, such as text boxes. Field update is triggered when the user moves focus away from the control after changing its value. To trigger an update with each keystroke, use the Immediate setting.

0 - None

True DataControl will not update the field until it is done in due course by Visual Basic, or the UpdateFields method is called. Use this setting when you don’t need automatic field updates, but prefer full programmatic control.

Note: Field update involves checking constraints and preventing the user from leaving control unless the constraints are satisfied. For more information, see Validation and Constraints. Some controls, such as Help and Cancel buttons, must be allowed to receive focus regardless of any constraints. These are controls whose CausesValidation property is set to False. True DataControl honors the CausesValidation setting. In 2 - Leaving control mode, it will not trigger a field update if the focus is moved to a control whose CausesValidation property is set to False.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback