Steps:
- Create a new data module unit
- Remove datamodule from list of auto-create forms in project options | Forms
- Remove global variable in the datamodule unit
- Select all the data components including data source components
- Copy the selected components onto the new data module
- Add a private member reference to the datamodule on the form
- Add create datamodule on form create and free datamodule on form destroy
- Save and build
- Remove data components from form.
- Save and build - this will give errors for each instance where the data component can now non longer be found.
- Go through this list of errors, correcting the reference to the components on the datamodule.
- Relink the data aware controls to the relevant datasource components on the data module.
- Relink the data component event handlers to the components. I exposed the event handlers on the form as an interface so that the data module could delegate the handling back to the form.
- Save and Build.
First off I'll convert a TDBEdit to TEdit. This should be done in two parts. The first part is to re-type the actual control. The second part will be replace functionality that would have been done by the data-aware events.
Retype steps:
- Make a note of the field that the data-aware control uses.
- View Form as Text
- Find the declaration of the TDBEdit to convert
- Change the type to TEdit.
- View form as Form
- Save. At this point the IDE will display messages saying that some of the additional property values of TDBEdit will be lost if you click 'Ignore'. This is what we want, so click 'Ignore All'.
- On Model change: enable/disable and populate control with current data field value
- On Post: populate insert/update query buffer data field value with the editor value.

No comments:
Post a Comment