ComponentOne True DataControl 8.0
RetrieveFields Method

 

RetrieveFields Method

Retrieves field layout from the source recordset.

Syntax

TData.RetrieveFields

Remarks

Method applies to TData control and TDataLite control.

Arguments: None

Return Value: None

The RetrieveFields method removes all fields from the collection and retrieves field definitions from the SourceRecordset.

This method is only allowed when DataMode = 0 (tdbModeDataSource). It is illegal to call RetrieveFields from any TData event procedure.

Calling RetrieveFields changes TData collections (namely, the Fields collection). According to general rules, that means you will need to set TData1.ChangeInProgress = True before doing that, and set TData1.ChangeInProgress = False once you are done with all changes, unless retrieving fields is meant to be the only change before TData automatically refreshes.

The method is useful in situations where the fields are not known beforehand, at design time, and it is necessary to change some collection settings once the SourceRecordset property is set: either modify field definitions retrieved from SourceRecordset, or to adjust some settings, for example, expressions, to the retrieved fields. If RetrieveFields is not called, TData retrieves fields from SourceRecordset automatically when it refreshes. If you want control over this process, call RetrieveFields explicitly after you set SourceRecordset, then you will be able to adjust collection settings to the newly retrieved fields before TData refreshes (TData will not retrieve fields on refresh if RetrieveFields was called explicitly).

Private Sub Form_Load()

    Dim cn As New ADODB.Connection

    Dim rs As New ADODB.Recordset

    TData1.ChangeInProgress = True

    cn.CursorLocation = adUseClient

    cn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\ComponentOne Studio\Common\TDDEMO.MDB;Persist Security Info=False")

    rs.Open "Customers", cn, adOpenStatic, adLockOptimistic, adCmdTable

    Set TData1.SourceRecordset = rs

    TData1.RetrieveFields

    TData1.Fields("CustomerID").Visible = False

    TData1.ChangeInProgress = False

    Set DataGrid1.DataSource = TData1

End Sub

See Also

TData Control

 

 


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

Product Support Forum  |  Documentation Feedback