Storage Mode > Interactions between True DBList and XArrayDB > Updating XArrayDB Elements |
It is important to note that when you change one or more elements in an XArrayDB object, you must refresh either the affected cells or the entire list, otherwise the display will not reflect the correct data. Consider the following example, which implements a command button that clears the contents of the current list row, and then sets focus to the list:
Example Title |
Copy Code
|
---|---|
Private Sub Command1_Click()
Dim row As Long, col As Integer
With TDBList1
row = .Bookmark
With MyArray
For col = .LowerBound(2) To .UpperBound(2)
.Value(row, col) = ""
Next col
End With
.RefetchRow
.SetFocus
End With
End Sub
|
Note that the Bookmark property of the list is used as a row index for the XArrayDB object. The loop that clears the current row also uses the LowerBound and UpperBound properties to iterate over the columns (second dimension) of the array. This technique will work with any XArrayDB object, although you can substitute integer constants if the array bounds are known in advance.
After the array elements are cleared, the list's RefetchRow method is invoked, causing all unmodified cells in the current row to be repainted as empty. Since no arguments are passed to the RefetchRow method, the list requests data for the current row.