Overview
TheTee.GridData.Strings unit provides two classes for working with string-based grid data:
- TVirtualModeData - A virtual data class for custom “Column x Row” grids using events
- 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)
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
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 objectAColumn- The column being queriedARow- The row indexAValue- Output parameter - set this to the cell value
TOnVirtualData
Event fired when the grid needs to update a cell value.Signature:Parameters:
Sender- The data objectAColumn- The column being updatedARow- The row indexAValue- The new cell value
Methods
procedure
Resizes the grid to the specified dimensions.Signature:Parameters:
AColumns- New number of columnsARows- New number of rows
function
Returns the zero-based index of a column.Signature:Parameters:
AColumn- The column to find
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)
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 indexRow- Zero-based row index
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
- Requires implementing event handlers
- You manage data storage
TStringsData
Pros:- Simple to use (like TStringGrid)
- No event handlers needed
- Easy data manipulation
- Stores all data in memory
- Higher memory usage for large datasets
See Also
- TVirtualData - Base virtual data class
- Strings Data Guide - Complete guide to string-based grids
- Custom Virtual Data - Creating custom data sources
- Basic Grid Example - Simple grid examples
