Overview
TeeGrid provides seamless integration with Delphi’s database components through theTVirtualDBData class. You can connect to any TDataSet or TDataSource component to display and edit database records in a grid.
Setting the
DataSource property automatically creates a TVirtualDBData instance — no manual setup required.Quick Start
The simplest way to bind a dataset is to assign it directly to the grid’sDataSource property:
Manual Binding
For more control, create aTVirtualDBData instance manually:
Master-Detail Grids
Create master-detail relationships using two grids and datasets:The grids automatically update when navigating through the master dataset. The detail grid shows related records based on the
MasterSource and MasterFields properties of your dataset.Column Mapping
TVirtualDBData automatically creates columns for all dataset fields. Each column is linked to its corresponding TField:
Field Properties
The grid respects field properties from your dataset:- Read-only fields: Non-editable columns
- Display format: Number and date formatting
- Alignment: Numeric fields auto-align right
- Field type: Determines column data type
Fetch Modes
Control how records are loaded from the dataset:Editing Data
When a cell is edited, changes are automatically written back to the dataset:Working with Fields
Access the underlyingTField objects:
Supported Datasets
TVirtualDBData works with any TDataSet descendant:
- FireDAC:
TFDQuery,TFDTable,TFDMemTable - dbExpress:
TSQLQuery,TSQLTable - ClientDataSet:
TClientDataSet - ADO:
TADOQuery,TADOTable - BDE:
TQuery,TTable(legacy)
Performance Tips
Large Datasets
Large Datasets
For datasets with thousands of records:
- Use
FetchMode := Partialto load only visible rows - Enable dataset buffering with
BufferCount - Consider server-side filtering and paging
- Use indexes for sorted columns
Network Databases
Network Databases
When connecting to remote databases:
- Use parameterized queries to reduce data transfer
- Fetch only required fields (
SELECT field1, field2) - Implement lazy loading for detail grids
- Cache frequently accessed data with
TFDMemTable
Real-time Updates
Real-time Updates
Handle dataset changes efficiently:
Data Source API Reference
TVirtualDBData Class
Key properties and methods:| Member | Description |
|---|---|
DataSet: TDataSet | The underlying dataset (read-only) |
FetchMode: TVirtualFetchMode | Controls record loading behavior |
OwnsData: Boolean | Whether the data object owns the dataset |
From(ASource: TComponent) | Factory method to create from TDataSet or TDataSource |
Events
The grid fires standard dataset events:BeforeEdit,AfterEditBeforePost,AfterPostBeforeDelete,AfterDeleteOnUpdateRecord
Common Issues
Next Steps
Arrays and Lists
Bind TArray<T> and TList<T> using RTTI
String Grids
Use TStringGrid-style string arrays
Custom Data
Create custom TVirtualData implementations
Grid API
Explore the complete TeeGrid API
