Disabling and Enabling Data Display

From RAD Studio
Jump to: navigation, search

Go Up to Using Common Data Control Features


When your application iterates through a dataset or performs a search, you should temporarily prevent refreshing of the values displayed in data-aware controls each time the current record changes. Preventing refreshing of values speeds the iteration or search and prevents annoying screen-flicker.

DisableControls is a dataset method that disables display for all data-aware controls linked to a dataset. As soon as the iteration or search is over, your application should immediately call the EnableControls method of the dataset to re-enable display for the controls.

Usually you disable controls before entering an iterative process. The iterative process itself should take place inside a try...finally statement so that you can re-enable controls even if an exception occurs during processing. The finally clause should call EnableControls. The following code illustrates how you might use DisableControls and EnableControls in this manner:

 CustTable.DisableControls;
 try
   CustTable.First; { Go to first record, which sets EOF False }
   while not CustTable.EOF do { Cycle until EOF is True }
   begin
     { Process each record here }
     { ... }
     CustTable.Next; { EOF False on success; EOF True when Next fails on last record }
   end;
 finally
   CustTable.EnableControls;
 end;

See Also