Data Binding
TTMSFNCDataBinder binds UI components to datasets at design time or runtime. It supports single-value bindings, list bindings (TStringList, TCollection, TList), column/list bindings, and grid bindings. It also auto-updates when dataset records change.
Key class: TTMSFNCDataBinder
Drop a TTMSFNCDataBinder component on the form and set it Active := True after configuring bindings.
Binding a Single Value
Show the value of a dataset field in a component property.
// Programmatic
TMSFNCDataBinder1.ConnectSingle(TMSFNCHTMLText1, DataSource1, 'Text', 'Common_Name');
TMSFNCDataBinder1.Active := True;
Or use an HTML template for richer formatting:
TMSFNCDataBinder1.ConnectSingleHTMLTemplate(
TMSFNCHTMLText1, DataSource1, 'Text', '<b>Name: <#COMMON_NAME></b><br/><#NOTES>');
TMSFNCDataBinder1.Active := True;
The <#FIELDNAME> placeholder is replaced with the field value. HTML is based on the TMS Mini HTML reference.

At design time, add items to the Items collection in the Object Inspector and set Object, BindType, DataSource, FieldName, and PropertyName directly.

Binding a List
Show all dataset records in a list component.
TStringList-based list:
TMSFNCDataBinder1.ConnectList(ListBox1, DataSource1, 'Items', 'Common_Name');
TMSFNCDataBinder1.Active := True;
TCollection-based list (use SubPropertyNames / SubFieldNames to bind collection item properties):
TMSFNCDataBinder1.ConnectList(
TMSFNCListBox1, DataSource1, 'Items',
['Text', 'Bitmap'], ['Common_Name', 'Graphic']);
TMSFNCDataBinder1.Active := True;

Binding a Column/List
Show all fields and records in a component with separate columns and list collections:
TMSFNCDataBinder1.ConnectColumnList(
TMSFNCTreeView1, DataSource1, 'Nodes', 'Columns', 'Text', 'Values.Text');
TMSFNCDataBinder1.Active := True;
The sub-property path Values.Text traverses a nested collection: for each node, a TTMSFNCTreeViewNodeValue is added to Values, and its Text property is set to the field value.

Binding a Grid
Bind to any component implementing ITMSFNCDataBinderGrid:
TMSFNCDataBinder1.ConnectGrid(TMSFNCGrid1, DataSource1);
TMSFNCDataBinder1.Active := True;

To support grid binding in a custom component, implement ITMSFNCDataBinderGrid:
ITMSFNCDataBinderGrid = interface(ITMSFNCDataBinderBase)
['{D23BDEAA-49B1-451A-9401-0D0D11A9957A}']
procedure SetDataColumnCount(AValue: Integer);
procedure SetDataRowCount(AValue: Integer);
procedure ClearData;
function GetDataRowCount: Integer;
procedure SetDataValue(AColumn, ARow: Integer; AValue: string);
procedure SetDataHeader(AColumn: Integer; AValue: string);
end;
Binding TList / TObjectList
TMSFNCDataBinder1.ConnectList(o, DataSource1, 'L', [], ['Price']);
TMSFNCDataBinder1.ConnectList(o, DataSource1, 'S', [], ['Brand']);
Supports TList<Integer>, TList<string>, and TObjectList<T>.
Runtime Editor
Open the visual binding editor at runtime:
TMSFNCDataBinder1.ShowEditor;
At design time, right-click the component and choose Edit….

Notification System
Use notifications to synchronize control changes back to the dataset.
Notification Types
| Type | Description |
|---|---|
dbntUpdate |
General update |
dbntEdit |
Put dataset in edit mode |
dbntPost |
Post changes to dataset |
dbntValueChanged |
Write control value to dataset |
dbntSetActiveRecord |
Sync active record from control selection |
Convenience Methods on TTMSFNCDataBinderItem
DataBinderItem.NotifyEdit; // put dataset in edit mode
DataBinderItem.NotifyValueChanged; // write the value
DataBinderItem.NotifyPost; // post changes
DataBinderItem.NotifyUpdate; // force general update
DataBinderItem.NotifySetActiveRecord; // sync active record
Global Notifications on TTMSFNCDataBinder
MyDataBinder.NotifyValueChanged;
MyDataBinder.NotifyEdit;
MyDataBinder.NotifyPost;
MyDataBinder.NotifyUpdate;
MyDataBinder.NotifySetActiveRecord;
Custom Control Integration
Implement ITMSFNCDataBinderNotification on a custom control to participate in the notification system. For automatic monitoring, the databinder supports IControlValueObserver and IEditLinkObserver.
Best Practices
- Prefer automatic monitoring for standard controls.
- Always ensure the dataset is in edit mode before writing values: check
DataBinderItem.DataSetCanModify. - Batch notifications with global methods when updating multiple controls.