Usage of bookmark and disablecontrols in layer-3 data cache

Source: Internet
Author: User
Delphi bookmark uses the bookmark operation. The bookmark operation is mainly used to quickly locate the record pointer in the table, and the position of the record pointer is often saved in applications, after other processing, you want to quickly return to the position where the previous pointer is located. In this case, using bookmarks is particularly useful. For the bookmark operation, Delphi provides three methods: ● getbookmark ● gotobookmark ● freebokmark, which are generally used together. The getbookmark method returns a variable of the tbookmark type, this variable contains pointers to the current record. The gotomark method is used to quickly locate the record pointer to a record with bookmarks. The freebookmark method is the opposite of the getbookmark method, which releases the bookmarks. The following code describes the general bookmark operation method: Bookmark: tbookmark; Bookmark: = table1.getbookmark; {mark the current record as a bookmark} table1.disablecontrols; {disconnect the connection between Table1 and the data detection component... table. first while not EOF do {Other processing of all records in the table} begin tabel1.next; end; tabel1.gotobookmark (bookmark) table1.enablecontrols; {reposition record pointer back to original position} tabel1.freebookmark (bookmark ); {Delete the bookmark mark }------------------------------------ ------------------------------------------ -The disablecontrols method is to cut off the data component when the program is modified or when a new record is refreshed in the background, such as tTable and adoquery. If no data changes are made to the data source, especially batch changes, each change will update the display of the data browsing component in the window, this slows down the processing process and wastes time. Enablecontrols serves the opposite purpose. It is used to restore the relationship between components such as tTable and datasource, and urge the data browsing component to update the display. These two functions mainly prevent the component from inductive display to speed up statement execution. For example, when using a large number of cycles, it is best to use them. 1. when the enablecontrols and disablecontrols methods of the dataset are used in pairs, if the code in the middle may lead to an error, try .. finaly disablecontrols; end; otherwise, data perception is not controlled and unavailable; 2. when traversing data or filtering big data, use dataset's enablecontrols and disabblecontrols. Otherwise, the data-aware control on the form will flash. enablecontrols and disablecontrols are used to prevent the UI from flashing due to changes to the data source! You can call these two functions when you need to refresh the data, but we recommend that you write them in try... finally statement block! For example, try adoquery1.disablecontrols; adoquery1.close; adoquery1.open; finally adoquery1.enablecontrols; end; the enablecontrols and disablecontrols methods of tquery are inherited from the tdataset class. Because tTable and tquery are both derived classes of tdataset, they both have the above two methods.

 

Usage of bookmark and disablecontrols in layer-3 data cache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.