Storage Mode > Interactions between True DBGrid and XArrayDB |
Add, update, and delete operations performed through True DBGrid's user interface or its properties and methods are automatically reflected in the attached XArrayDB object. For example, if the following code is executed:
Example Title |
Copy Code
|
---|---|
With TDBGrid1
.Text = "New value"
.Update
End With
|
then the current cell of the grid and the corresponding element of the associated XArrayDB object are automatically updated, and the following expression will be True (assuming that the second array dimension is zero-based):
Example Title |
Copy Code
|
---|---|
MyArray(TDBGrid1.Bookmark, TDBGrid1.Col) = "New value"
|
However, the reverse is not true. If you insert or delete XArrayDB rows or columns directly in code, or even change the value of a single element, the grid does not receive any notifications from the XArrayDB. Therefore, you must either Refresh, ReBind, or ReOpen the grid in order to update the display.
You can follow two rules of thumb to ensure that the display is updated properly:
If you insert or delete XArrayDB columns or rows in code, you are changing the structure of the underlying data source. Therefore, you should invoke the grid's ReBind or ReOpen method.
If you change the value of one or more array elements in code, you are changing the underlying data source without altering its structure. Therefore, you should invoke the grid's Refresh method.