Overview
TeeGrid provides two classes for string-based grid data, similar to VCL’sTStringGrid:
TStringsData: Maintains an internal 2D array of strings (like TStringGrid)TVirtualModeData: Virtual mode with events for custom data storage
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:Column Headers
Set custom header text for each column:Performance Optimization
For large grids (millions of cells), optimize rendering:Speed Tips for Large Grids
Speed Tips for Large Grids
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
CompleteTStringGrid 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
CSV Import
CSV Import
Import CSV data into TStringsData:
Formula Calculation
Formula Calculation
Use TVirtualModeData for spreadsheet-like formulas:
Search Highlight
Search Highlight
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
