Functions of Disablecontrols and Enablecontrols in Delphi database technology
2010-12-06 10:48:43| Category: Delphi Technology | Tags: disablecontrols enablecontrols | font size Big Small subscription
In general, the program used to scan the entire database table and modify one field per record is as follows:
With Table do
Begin
Disablecontrols; {Invalidates other parts during record modification}
First; {Point The Record pointer to the first record}
While don't EOF do
Begin
< read a field value from a record into a variable >
< make the appropriate changes >
Edit; {Place ttable part in edit state}
< write the modified field values back to their corresponding fields >
Post {Write the modified record back to the database}
Next {Modify Next record}
End
Enablecontrols; {Restore functionality of other parts}
End
The program operates on ttable parts, so it makes sense to use the WITH statement to prevent erroneous proliferation. Here you should pay attention to the use of the Disablecontrols method and the Enablecontrols method. The Disablecontrols method is to cut off the ttable part's contact with the data Access part Tdatasource part when the program modifies the record in the ttable part. Otherwise, after each modification in ttable, the Tdatasource part updates the display of all the data-browsing parts in the form, which slows down the process and wastes time dramatically. The Enablecontrols method is the opposite of the Disablecontrole method, which is used to restore the connection of the ttable part to the Tdatasource part and to facilitate all data browsing parts
Turn: Functions of Disablecontrols and Enablecontrols in Delphi database technology