Delphi ADOQuery method of DisableControls and EnableControls

DisableControls method is to cut off the program modifications or background have set records when data components, such as TTABLE, ADOQUERY etc. contact with the component data source. If you do not cut off, the data source as long as there is a change of data, particularly bulk changes, then changes will be updated every sum of the data in the browser window display components, this will dramatically slow down the process but also a waste of time.

EnableControls effect, contrary to restore contact TTABLE and other components and DATASOURCE and prompted to update the display data browsing component.

The main role of these two functions: to prevent sensitive display components, in order to speed up the statement execution speed.  For example, with plenty of circulation, the best use of them.

Precautions:     

EnableControls 1. dataset, when used in pairs DisableControls method, if the intermediate code may lead to an error, then must try..finaly DisableControls; end; otherwise, data control perceptually unavailable;     

2. In the use of large data through the data or Filter time of  the DataSet  EnableControls and DisabbleControls, otherwise data-aware controls on a form flashes .enablecontrols, disablecontrols is to prevent changes to the data source interface caused flash! When you need to refresh the data can be called up these two functions, but it is recommended that you write it in

try ... finally statement block! Such as:   

 try   
      ADOQuery1.disablecontrols;   
      ADOQuery1.close;   
      ADOQuery1.open;   
  finally   
      ADOQuery1.enablecontrols;   
  end;  

   TQuery of EnableControls DisableControls and methods are inherited from TDataSet class. Because TTable and TQuery are TDataSet derived class,

   They are also applicable to the above two methods. 

 

Guess you like

Origin www.cnblogs.com/guorongtao/p/11410289.html