Skip to main content

Overview

TeeGrid provides two classes for string-based grid data, similar to VCL’s TStringGrid:
  • TStringsData: Maintains an internal 2D array of strings (like TStringGrid)
  • TVirtualModeData: Virtual mode with events for custom data storage
Both provide a simple column × row grid without complex data binding.

TStringsData: String Array Storage

TStringsData stores cell values in memory, perfect for replacing TStringGrid:
TStringsData uses the default property Cells[Column, Row] so you can use array syntax: Data[Col, Row]

Creating and Resizing

Multiple ways to initialize grid size:

Working with Cells

Access and modify cell values:
TeeGrid automatically handles multi-line text. Enable TeeGrid1.Rows.Height.Automatic := True to adjust row heights dynamically.

Column Headers

Set custom header text for each column:

Performance Optimization

For large grids (millions of cells), optimize rendering:
When displaying huge grids (1000 × 100,000 = 100 million cells):
  • Disable alternating row colors: TeeGrid1.Rows.Alternate.Hide
  • Disable header gradients: TeeGrid1.Header.Format.Brush.Gradient.Hide
  • Hide scrollbars if not needed: TeeGrid1.ScrollBars.Visible := False
  • Use fixed row height: TeeGrid1.Rows.Height.Value := 24
  • Provide default column width in constructor

TVirtualModeData: Event-Driven

TVirtualModeData doesn’t store data internally — you provide values through events:
Virtual Mode Benefits: No memory overhead for cell storage. Perfect for computed values, database-backed data, or grids with billions of cells.

Real-World Example

Complete TStringGrid replacement example:

Custom Cell Rendering

Override cell painting for custom display:

Cell Formatting

Apply custom formatting to specific cells:

Sub-Bands (Grouping Rows)

Insert separator bands between rows:

Comparison: TStringsData vs TVirtualModeData

Common Patterns

Import CSV data into TStringsData:
Use TVirtualModeData for spreadsheet-like formulas:
Highlight search results:

Next Steps

DataSet Binding

Connect to TDataSet and TDataSource

Arrays and Lists

Bind TArray<T> and TList<T> using RTTI

Custom Data

Create custom TVirtualData implementations

Rendering API

Customize cell appearance and painting