Unbound Mode > Unbound Mode Events > UnboundReadDataEx event examples |
The following examples assume a dataset containing 100 rows, numbered 0 to 99. Thus, when calculating bookmark positions, a negative row number denotes BOF, and a row number greater than or equal to 100 denotes EOF.
Example 1:
Example Title |
Copy Code
|
---|---|
RowBuf.RowCount = 1
RowBuf.ColumnCount = 0
StartLocation = Bookmark for row 8
Offset = -1
|
In this example, 1 row and 0 columns are being requested, so the event handler must supply a bookmark only. Since Offset is -1, the list is asking for the row before row 8, and the event handler should respond as follows:
Example Title |
Copy Code
|
---|---|
RowBuf.Bookmark(0) = Bookmark for row 7
RowBuf.RowCount = 1
ApproximatePosition = 7
|
Example 2:
Example Title |
Copy Code
|
---|---|
RowBuf.RowCount = 10
RowBuf.ColumnCount = 5
StartLocation = Bookmark for row 80
Offset = 15
|
In this example, the list is asking for 10 rows of data starting with row 95 (80 + 15). Thus, the list wants data from rows 95 to 104, in ascending order. However, rows 100 to 104 do not exist in the dataset, so the event handler returns as many rows as it can:
Example Title |
Copy Code
|
---|---|
RowBuf.Bookmark(0) = Bookmark for row 95 RowBuf.Value(0, ColIndex) = Data for row 95 ... RowBuf.Bookmark(4) = Bookmark for row 99 RowBuf.Value(4, ColIndex) = Data for row 99 RowBuf.RowCount = 5 ApproximatePosition = 95 |
Example 3:
Example Title |
Copy Code
|
---|---|
RowBuf.RowCount = 10 RowBuf.ColumnCount = 2 StartLocation = Null Offset = -13 |
In this example, the list is asking for 10 rows of data. Since StartLocation is Null, and since Offset is negative, the list wants data starting at 13 rows before EOF. Since the last valid row is 99, row 100 denotes EOF, and the first requested row is 87 (100 - 13). Thus, the list wants data from rows 87 to 96, in ascending order, and the event handler should respond as follows:
Example Title |
Copy Code
|
---|---|
RowBuf.Bookmark(0) = Bookmark for row 87 RowBuf.Value(0, ColIndex) = Data for row 87 ... RowBuf.Bookmark(9) = Bookmark for row 96 RowBuf.Value(9, ColIndex) = Data for row 96 RowBuf.RowCount = 10 ApproximatePosition = 87 |
Example 4:
Example Title |
Copy Code
|
---|---|
RowBuf.RowCount = 1 RowBuf.ColumnCount = 0 StartLocation = Null Offset = 1 |
In this example, the list is asking for a bookmark, since 1 row and 0 columns are being requested. Since StartLocation is Null and Offset is positive, the request is relative to BOF. Since Offset is 1, the bookmark requested is that of the first row of the dataset. This example corresponds to the initial firing of UnboundReadDataEx when the list is first loaded, and the event handler should respond as follows:
Example Title |
Copy Code
|
---|---|
RowBuf.Bookmark(0) = Bookmark for row 0
RowBuf.RowCount = 1
ApproximatePosition = 0
|
Example 5:
Example Title |
Copy Code
|
---|---|
RowBuf.RowCount = 1
RowBuf.ColumnCount = 0
StartLocation = Bookmark for row 6
Offset = -15
|
In this example, the list is asking for a bookmark, but the row requested (6 - 15 = -9) does not exist, since the first valid data row is 0. In this case, the event handler should respond as follows:
Example Title |
Copy Code
|
---|---|
RowBuf.RowCount = 0 Exit Sub |
This is also the correct response when there are no records in the dataset.