BindingSource is not pointing to the last changed data in th

Posted by VikasDugar on 10-Mar-2017 08:37

Hi,

I have a dataset handle returning from a class. 

And this handle is attached to the bindingsource -> ultragrid. 

And after some filter criteria the values in the dataset are changed but values in the ultragrid are not refreshed.

the dataset has the new set of values but these values are not available in the bindingsource. 

Can any one help me on this?

Thanks!

Regards,

Vikas.

Posted by Laura Stern on 10-Mar-2017 12:43

You just need to reopen the query.  PLEASE do not set the handle property of the BindingSource to unknown and reset.  That should never be necessary and is a big waste of time.  It will refresh its schema and everything else that has not actually changed.

The BindingSource works off of a query result set.  If the query is not reopened, the record count may be wrong, which is critical for the grid to work correctly, and at least for the records that you've already scanned through it would be trying to read that original set, not anything related to the new records.

And if the AutoSync property of the BindingSource is true, which it is by default, you don't even have to call the Refresh method.  The query open will take care of it.

All Replies

Posted by Peter Judge on 10-Mar-2017 08:46

The BindingSource has Refresh() and RefreshAll() methods that you can look at.
 

Posted by VikasDugar on 10-Mar-2017 09:10

Thanks Peter.
Those methods didnt work. When i try to read the record count in the bindingsource it always return with the inital value (called for first time).

Second time the dataset has different number of records but binding source do not.

Posted by Peter Judge on 10-Mar-2017 09:32

Then you need to (basically) reopen the query. Or force the binding source to do so. Set the Handle property to ? and then DATASET:HANDLE and it should do the trick.
 
You’ll have to reposition back to the original record (if it’s still there).
 

Posted by Laura Stern on 10-Mar-2017 12:43

You just need to reopen the query.  PLEASE do not set the handle property of the BindingSource to unknown and reset.  That should never be necessary and is a big waste of time.  It will refresh its schema and everything else that has not actually changed.

The BindingSource works off of a query result set.  If the query is not reopened, the record count may be wrong, which is critical for the grid to work correctly, and at least for the records that you've already scanned through it would be trying to read that original set, not anything related to the new records.

And if the AutoSync property of the BindingSource is true, which it is by default, you don't even have to call the Refresh method.  The query open will take care of it.

Posted by VikasDugar on 13-Mar-2017 08:20

Thanks Laura Stern. Mapping the bindingsource to the Query handle worked.

This thread is closed