Skip to main content

Overview

The Tee.GridData.Strings unit provides two classes for working with string-based grid data:
  1. TVirtualModeData - A virtual data class for custom “Column x Row” grids using events
  2. TStringsData - A TStringGrid emulator that maintains an internal array of strings
These classes are perfect for creating simple grids without database binding, similar to the traditional TStringGrid component.

TVirtualModeData

A lightweight virtual data class that uses events to provide cell values on-demand.

Constructor

constructor
Creates a new virtual mode data instance.Signature:
Parameters:
  • AColumns - Initial number of columns (default: 0)
  • ARows - Initial number of rows (default: 0)
  • DefaultWidth - Optional default column width for faster rendering (default: 0)
Example:

Properties

Integer
default:"0"
Gets or sets the number of columns in the grid.Example:
Integer
default:"0"
Gets or sets the number of rows in the grid.Example:
String
Gets or sets the header text for a specific column.Signature:
Parameters:
  • Column - Zero-based column index
Example:
TColumns
Provides read-only access to the internal columns collection.Example:

Events

TOnVirtualData
Event fired when the grid needs to retrieve a cell value.Signature:
Parameters:
  • Sender - The data object
  • AColumn - The column being queried
  • ARow - The row index
  • AValue - Output parameter - set this to the cell value
Example:
TOnVirtualData
Event fired when the grid needs to update a cell value.Signature:
Parameters:
  • Sender - The data object
  • AColumn - The column being updated
  • ARow - The row index
  • AValue - The new cell value
Example:

Methods

procedure
Resizes the grid to the specified dimensions.Signature:
Parameters:
  • AColumns - New number of columns
  • ARows - New number of rows
Example:
function
Returns the zero-based index of a column.Signature:
Parameters:
  • AColumn - The column to find
Returns: The column’s index, or -1 if not found.

Complete Example

TStringsData

Derived from TVirtualModeData, this class maintains an internal array of strings for each cell, similar to TStringGrid.

Constructor

constructor
Creates a new strings data instance.Signature:
Parameters:
  • AColumns - Initial number of columns (default: 0)
  • ARows - Initial number of rows (default: 0)
Example:

Properties

String
default:true
Gets or sets the value of a specific cell. This is the default array property.Signature:
Parameters:
  • Column - Zero-based column index
  • Row - Zero-based row index
Example:
All properties from TVirtualModeData are also available (Columns, Rows, Headers, etc.).

Complete Example

Dynamic Data Modification

Importing from CSV

Performance Comparison

TVirtualModeData

Pros:
  • Minimal memory usage (no data stored internally)
  • Perfect for very large datasets
  • Data stays in your own data structures
Cons:
  • Requires implementing event handlers
  • You manage data storage
Best for: Large datasets (1M+ rows), computed values, data from external sources

TStringsData

Pros:
  • Simple to use (like TStringGrid)
  • No event handlers needed
  • Easy data manipulation
Cons:
  • Stores all data in memory
  • Higher memory usage for large datasets
Best for: Small to medium datasets (up to 100K rows), simple grids, quick prototypes

See Also