Skip to main content

Overview

TeeGrid provides seamless integration with Delphi’s database components through the TVirtualDBData 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’s DataSource property:

Manual Binding

For more control, create a TVirtualDBData 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:
Use TVirtualFetchMode.All for small datasets where you need accurate row counts. Use Automatic or Partial for large datasets to improve performance.

Editing Data

When a cell is edited, changes are automatically written back to the dataset:

Working with Fields

Access the underlying TField 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

For datasets with thousands of records:
  • Use FetchMode := Partial to load only visible rows
  • Enable dataset buffering with BufferCount
  • Consider server-side filtering and paging
  • Use indexes for sorted columns
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
Handle dataset changes efficiently:

Data Source API Reference

TVirtualDBData Class

Key properties and methods:

Events

The grid fires standard dataset events:
  • BeforeEdit, AfterEdit
  • BeforePost, AfterPost
  • BeforeDelete, AfterDelete
  • OnUpdateRecord

Common Issues

Dataset not active: Ensure your dataset is Active := True before assigning to the grid.
Read-only dataset: Check that your dataset’s CanModify returns True if you need editing support.

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