Application Mode > Application Mode Bookmarks |
In application mode, a bookmark is a variant supplied by your application and used by the grid as a means of uniquely identifying a row of data to be displayed or modified.
Just as your application provides, stores, and maintains the data for the unbound grid, you must deal similarly with the bookmarks. The bookmarks themselves must be supplied by your code in the UnboundGetRelativeBookmark, ClassicRead, and ClassicAdd events as variant data. You are free to use whatever you choose for the purpose of identifying a row, but keep in mind that the bookmarks must be unique for each row. In general, you will also want to be able to search for the associated record quickly when given a bookmark. Three common examples of what to use for bookmarks are:
If you use the unbound grid with a proprietary database, you can use the values of a unique key field as bookmarks. That way, when given a bookmark, you can search and retrieve the associated record quickly.
If the database you use supports unique row IDs or record numbers, these can be conveniently used as bookmarks.
If you use the grid to display an array, the array's row index is an obvious choice for bookmarks.
Bookmarks cannot exceed 255 characters in length. Since Visual Basic 5.0 uses 2 bytes per character, this means that string bookmarks cannot exceed 127 characters.
True DBGrid's application mode supports string, integral, and floating point bookmarks. All other data types must be converted to strings before they are passed to the grid as variant bookmarks.
Since True DBGrid and Visual Basic differ in their treatment of bookmarks, some restrictions apply when manipulating them in code, as discussed in the following sections.