ComponentOne True DataControl 8.0
Refresh Method

 

Refresh Method

Refetches all data.

Syntax

TData.Refresh [NoEvents]

Remarks

Method applies to TData control and TDataLite control.

Arguments: NoEvents is an optional Boolean argument that controls event firing during a refresh. The default value is False.

Return Value: None

This method refreshes the TData control Recordset by refetching all data from the data source. The TData control positions on the first row after a refresh.

In DataMode = 0 - DataSource, the Refresh method re-establishes the database connection if at least one of the data source properties of the TData control has been changed. Otherwise, it just refetches the data from SourceRecordset. This can be useful if you need to synchronize TData with somehow changed contents of SourceRecordset. If you need to synchronize with the changes made to the database by other users, bear in mind that the Refresh method will not do that automatically, since such changes are not yet reflected in SourceRecordset. To ensure that TData shows the latest state of the database, use Refresh in conjunction with the ADO Requery method:

TData1.SourceRecordset.Requery

TData1.Refresh True

If the NoEvents argument is False (default), the WillOpenData, OpenData and OpenDataComplete events are fired in the refresh. If NoEvents argument is True, no events are fired; the TData control refreshes its recordset and notifies all bound controls about the change.

When the Refresh method is called, the TData control re-establishes the database connection if necessary (if data source properties have changed). Before doing this, if NoEvents=False (default), it fires the WillOpenData event. If the code in WillOpenData changes collections, TData adjusts itself to the new collection settings. Then the OpenData event is fired. The OpenData event gives you an opportunity to set the SourceRecordset property to a desired recordset (or to set the Array property in DataMode = 1 - MemoryArray). After that, the source recordset is re-queried or recreated, if necessary. Once all of this is done, the OpenDataComplete event fires.

A special case of the Refresh method is when it is called with NoEvents=True (Refresh True). Then no events are fired. This case is useful when the programmer knows that underlying data have changed, but all the TData control settings remain the same. For example, in DataMode = 1 - MemoryArray, after modifying the XArrayDB object in code, Refresh True should be called to refresh data shown in the TData control. An exception to this rule is when the change is made in the OpenData event, in which case you should not call Refresh. A refresh with NoEvents = True can be used in other data modes too. In DataMode = 2 - UserEvents, it should be called after some intrinsic data or state changes, to refetch the data. It can also be used in DataMode = 0 - DataSource, to reflect changes made to the SourceRecordset, although it is rarely needed. Most changes made to SourceRecordset, for example, setting Filter or Sort, are reflected by the TData control automatically.

You do not have to call Refresh after making changes to True DataControl collections, since the refresh will occur automatically, see Modifying True DataControl collections from code.

See Also

TData Control

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback