Object Reference > True DBGrid Events > UnboundReadData Event |
UnboundReadData Event
The UnboundReadData event is fired when an unbound grid (one with its DataMode property set to 1 - Unbound) requires data for display, such as when it is first loaded or the user scrolls the grid display.
object_UnboundReadData (ByVal RowBuf As TrueDBGrid80.RowBuffer, StartLocation As Variant, ByVal ReadPriorRows As Boolean)
Arguments
RowBuf is a RowBuffer object used to transfer row data to the grid.
StartLocation is a variant bookmark that identifies the row to position to before fetching the next or previous page of records. If Null, the grid is requesting the first or last page of records as determined by the ReadPriorRows argument.
ReadPriorRows is a Boolean that determines the direction in which rows are to be fetched. If True, the grid is requesting records that precede StartLocation. If False, the grid is requesting records that follow StartLocation.
The RowBuf argument acts like a two-dimensional array of variants corresponding to the grid cells being fetched. By populating its Value property with the appropriate data, your event procedure transfers rows from the unbound dataset to the grid.
Use the row buffer's RowCount property to determine how many rows of data the grid is requesting. Use its ColumnCount property to determine the number of columns to be populated.
The RowBuf argument is also used to store a set of variant bookmarks that uniquely identify rows in the unbound dataset. The format of these bookmarks is determined solely by your application. For example, they may be primary key fields, row numbers, or array indexes, depending upon the nature of the unbound dataset.
Your event procedure supplies bookmarks to the grid by populating the row buffer's Bookmark property for each row returned. Keep in mind that the bookmarks you provide in the UnboundReadData event may be subsequently passed to the UnboundWriteData and UnboundDeleteRow events depending on how the user interacts with the grid. In addition, bookmark-based TDBGrid properties and methods such as Bookmark, FirstRow, GetBookmark, and RowBookmark are also designed to work with these unbound bookmarks.
It is not necessary to fill the row buffer completely, and it is in fact acceptable to return no rows at all. The row buffer's RowCount property can be set to indicate that fewer rows were returned than requested. The grid interprets this to mean that there are no more rows to retrieve in the indicated direction. Thus, it is only necessary to fill the row buffer completely if there are more valid rows to be retrieved.
Note
True DBGrid is very conservative in its assumptions about row counts and BOF/EOF conditions. As a result, it may seem that the UnboundReadData event fires "too often." This should not be interpreted as a sign of inefficiency, but rather as an assurance that an unbound grid performs accurately with large multiuser databases.