Overview
TeeGrid is built on a flexible, framework-agnostic architecture that separates the visual grid component from its data source. This design allows TeeGrid to work seamlessly across VCL, FireMonkey, and Lazarus frameworks.Core Architecture
The TeeGrid architecture consists of three main layers:TCustomTeeGrid: The Core Class
TCustomTeeGrid is the abstract base class that defines all grid functionality. It’s located in Tee.Grid.pas and serves as the foundation for framework-specific implementations.
Key Properties
The data source for the grid. This property connects your data to the grid through the virtual data abstraction layer.
Collection of grid columns that define the structure and appearance of your data.
Controls row rendering, including height, spacing, alternating colors, and cell hover effects.
The main row group that manages the primary data display and potential hierarchical sub-groups.
Manages cell selection state, including single cell and range selection.
Component Hierarchy
The grid is composed of several key components:TRowGroup - Data Grouping
TRowGroup - Data Grouping
TRowGroup manages a set of rows with associated data and columns. It supports:- Main data display through the
Rootproperty - Hierarchical data with expandable sub-groups
- Independent scrolling and selection within each group
TGridBands - Header/Footer Areas
TGridBands - Header/Footer Areas
TIndicator - Row State Display
TIndicator - Row State Display
TIndicator is a special column that appears on the left side:- Shows current row selection with a triangle symbol
- Displays edit/insert state
- Configurable width through
Indicator.Widthproperty
Framework-Specific Implementations
TeeGrid provides concrete implementations for different frameworks:VCL: VCLTee.Grid
FireMonkey: FMXTee.Grid
Lazarus: LCLTee.Grid
Rendering Pipeline
The grid uses an abstract painting system through theTPainter class, which provides framework-agnostic drawing operations:
Layout Calculation
The grid calculates column widths, row heights, and positions for all visible elements.
Band Rendering
Header and footer bands are rendered first, establishing the available space for rows.
Row Rendering
Visible rows are painted using the
TRows component, which:- Applies alternating row colors if configured
- Renders each cell using the column’s render settings
- Highlights selected cells
- Shows hover effects
Data Flow
Understanding how data flows through TeeGrid is crucial:Key Design Patterns
Abstract Data Pattern
TeeGrid uses theTVirtualData abstract class to decouple the grid from specific data sources. This enables:
- Support for any data source through custom implementations
- Lazy data loading for large datasets
- Virtual mode with on-demand cell value retrieval
Component-Based Rendering
All visual elements inherit fromTRender, providing:
- Consistent formatting through
TFormat(brush, stroke, font) - Custom painting via render classes
- Reusable visual components across different grid parts
Event-Driven Updates
The grid uses event notifications to stay synchronized:OnRefresh: Data source structure changedOnRepaint: Visual update neededOnChangeRow: Current row changedOnEditing: Edit mode started/stopped
State Management
TeeGrid maintains several state properties:Selection State
- Current column and row
- Selection range (if enabled)
- Unfocused selection appearance
Editing State
- Active editor control
- Edit mode (insert/edit)
- Modified cell values
Scroll State
- Horizontal scroll position
- Vertical scroll position
- First visible row index
Layout State
- Calculated column positions
- Row heights (if custom)
- Expanded/collapsed groups
Thread Safety and Updates
To refresh the grid after data changes:Memory Management
TeeGrid follows standard Delphi component ownership rules. The grid owns its columns, bands, and internal objects. When you assign a
TVirtualData instance, set its ownership appropriately.Next Steps
Data Binding
Learn how to connect your data to TeeGrid
Column System
Understand the column hierarchy and configuration
Virtual Data
Deep dive into the data abstraction layer
API Reference
Explore the complete API documentation
