TGrid and TStringGrid are very similar from the functionality point of view, but there is a significant difference in terms of the data to be displayed; that is, TGrid does not hold the data it is showing. To provide data for each cell, you must implement the OnGetValue event handler.
This handler will be called each time the grid needs a value for a cell, but it will not actually be stored within the grid. There is a caching mechanism to improve performance and avoid multiple unnecessary requests to the OnGetValue implementation, but the cache only contains data for the visible cells and it is cleared as soon as the cell goes beyond the scope of visibility. If you need to solicit the grid to refresh data shown to the user, you will have to instruct the grid model that some data has changed. The following code block shows a simple implementation of the OnGetValue event handler, providing (mostly random) values for a grid with three...