Object Reference > True DBGrid Events > DataSourceChanged Event |
DataSourceChanged Event
The DataSourceChanged event occurs when a bound data source is changed or requeried. This event also fires when a bound grid control is first loaded.
object_DataSourceChanged ( )
Arguments
None
The DataSourceChanged event fires before the grid is filled with data. Therefore, you can use this event to initialize the grid according to information obtained from the data source, if necessary.
This event does not fire in unbound or storage modes.
Note
With the OLE DB version of True DBGrid, you can use the DataSourceChanged event in conjunction with the BookmarkType property to circumvent type mismatch errors that may occur when a grid-supplied bookmark is passed to an ADO Recordset object (or vice versa). The workaround is as follows:
Sub TDBGrid1_DataSourceChanged()
TDBGrid1.BookmarkType = VarType(ADODC1.Recordset.Bookmark)
End Sub
This code ensures that any bookmarks returned by the grid are first converted to the appropriate type for the bound data source. This workaround is only needed when using the grid in an HTML page; it is not needed for Visual Basic 6.0.