I am using a few DataGridViews
with BindingSources
. One of these DataGridViews
is used to display details for a Child Property of another BindingSource
.
The child object details are not immediately displayed on the screen (I'm using DevExpress XtraTabControl
) and I want to load the child property only when the user displays the tab of that child property.
The child property is retrieved from the database, but as this can take a while it is only loaded the when it is first accessed and subsequent retrievals access the now cached object.
The problem seems to be that creating the BindingSource
bindings immediately accesses the Child Property (and therefore accesses the database for every child property, and there are quite a few).
Is it possible to have Child Binding Sources only access the property when it is being displayed?
You can connect your BindingSource to your database at the convenient time, for example when handling the XtraTabControl.SelectedPageChanged
or TabControl.SelectionChanged
event.
Just set its DataSource
property:
myBindingSource.DataSource=myDataSource;