Calling TDataSet.DisableControls
disables the link between master/detail datasets. Is there another way to disable updating data-aware controls without affecting the master/detail relationship? I know I can set individual component's DataSource
to nil
, but this isn't the practical way for me.
Asked
Active
Viewed 2,639 times
2

iMan Biglari
- 4,674
- 1
- 38
- 83
2 Answers
2
This solution presumes you use separate TDataSource
instances for linking UI controls and for Master-Detail relations which - from a design perspective - is a good idea anyway.
The drawback of this solution: this cause some flickering in your UI.
You could:
- Enumerate all
TDataSource
instances that point to yourTDataSet
instances but are not involved in Master-Detail relations. - For each of those instances, save the
Enabled
property. - For each of those instances, set the
Enabled
property toFalse
- Run your logic
- For each of those instances, restore the
Enabled
property.

Jeroen Wiert Pluimers
- 23,965
- 9
- 74
- 154
-
1Seems like a good idea to write a class which can enumerate datasources and maintain these links. Then instantiate an instance per data module that needs such management tasks. – Warren P Sep 01 '12 at 16:31
-
Neat idea, but not practical in my case. I have a database action which duplicates the current record of associated dataset, with all of the corresponding detail records. I have no idea if the user has twin datasources per dataset or not. – iMan Biglari Sep 02 '12 at 06:26
-
Duplication of data usually is not such a good idea. Why do you need that? – Jeroen Wiert Pluimers Sep 03 '12 at 09:37
1
Nowadays you have a perfect option to achieve this. As the Delphi Help states:
If the dataset is the master of a master/detail relationship, calling DisableControls also disables the master/detail relationship. Setting BlockReadSize instead of calling DisableControls updates the detail datasets as you scroll through the dataset, but does not update data-aware controls.

Carlos B. Feitoza Filho
- 704
- 7
- 23