Overview
TeeGrid for Lazarus provides cross-platform grid components using the FreePascal compiler and LCL (Lazarus Component Library). Share the same VCL codebase across Windows, Linux, macOS, and other FreePascal-supported platforms.Lazarus uses the same
VCLTee.Grid unit as Delphi VCL, with FPC-specific conditional compilation for compatibility.Installation
Setting Up TeeGrid in Lazarus
1
Clone the TeeGrid repository
2
Open your Lazarus project
Launch Lazarus IDE and open your project or create a new application.
3
Add units to your uses clause
4
Configure library paths
Add TeeGrid source directories to your project search path:
- Project → Project Options → Compiler Options → Paths
- Add to “Other unit files”:
TeeGrid/src/delphi/VCLTeeGrid/src/delphi
Platform Support
Lazarus with TeeGrid supports multiple platforms:Windows
- Win32
- Win64
- Full GDI support
Linux
- x86_64
- ARM
- GTK2/GTK3/Qt5 widgets
macOS
- Intel (x86_64)
- Apple Silicon (AArch64)
- Cocoa widget set
Additional Platforms
- FreeBSD: x86_64, i386
- Raspberry Pi: ARM Linux
- Other Unix: Most POSIX-compatible systems
FreePascal Compatibility
Conditional Compilation
TeeGrid uses{$IFDEF FPC} directives for FreePascal compatibility:
VCLTee.Grid.pas
Object Pascal Mode
Enable Object Pascal mode for Delphi compatibility:{$mode objfpc}: Object Pascal mode (Delphi-compatible){$H+}: Long strings (AnsiString) by default
Architecture
Shared VCL Implementation
Lazarus uses the same classes as Delphi VCL:LCL-Specific Members
VCLTee.Grid.pas:104
Rendering
LCL Painter
Uses the sameTGDIPainter with LCL adaptations:
VCLTee.Painter.pas
- Native LCL canvas drawing
- Platform-specific optimizations
- GTK/Qt/Cocoa widget rendering
Database Integration
Supported Database Components
Lazarus TeeGrid works with various database components:- TDbf (DBF Files)
- SQLdb (Built-in SQL)
- ZeosLib
Complete Database Example
Lazarus Database Application
Lazarus Database Application
unit_main.pas
Cell Editing
LCL Editor Controls
Lazarus supports standard LCL editor controls:Platform-Specific Editors
Some editors may behave differently across widget sets:Messages and Events
LCL Messages
Lazarus uses LCL message types:VCLTee.Grid.pas:129
LM_SIZE- Component resizedLM_PAINT- Repaint neededLM_SETFOCUS- Component gained focusLM_KILLFOCUS- Component lost focus
Scrolling
LCL ScrollBars
Scrollbars work the same as in VCL:Themes
LCL Widget Themes
TeeGrid adapts to the native LCL theme:Platform Native Appearance
- GTK2/GTK3 (Linux)
- Qt5 (Linux/Windows)
- Cocoa (macOS)
- Win32/Win64 (Windows)
TeeGrid automatically uses GTK theme colors and fonts.
Master-Detail Grids
Two-Grid Master-Detail
Master-Detail with Two TeeGrids
Master-Detail with Two TeeGrids
unit_masterdetail_twogrids.pas
Performance Optimization
Lazarus-Specific Tips
Widget Set Selection
Widget Set Selection
Choose the appropriate widget set for your target platform:
- GTK2: Fastest on older Linux systems
- GTK3: Modern Linux with better HiDPI support
- Qt5: Best cross-platform consistency
- Cocoa: Required for macOS
- Win32/Win64: Native Windows performance
Disable Visual Themes
Disable Visual Themes
Optimize Compiler Settings
Optimize Compiler Settings
Dataset Scrolling
Dataset Scrolling
Common Issues
Troubleshooting
Unit not found errors
Unit not found errors
Problem:
Fatal: Cannot find VCLTee.Grid used by...Solution:- Add TeeGrid source paths to Project Options → Paths
- Add:
TeeGrid/src/delphi/VCLandTeeGrid/src/delphi - Rebuild project
Type mismatch with TDataSource
Type mismatch with TDataSource
Problem:
Incompatible type for arg no. 1: Got "TDataSource", expected "TComponent"Solution:Access violation on Linux
Access violation on Linux
Problem: Crashes on GTK2/GTK3Solution:
- Check for nil objects before accessing
- Use try-finally blocks for resource cleanup
- Test with different widget sets (GTK2 vs GTK3)
High DPI display issues
High DPI display issues
Problem: Blurry text or small controls on HiDPI screensSolution:
Complete Example
Full Lazarus Application
Full Lazarus Application
unit_main.pas
Deployment
Building for Distribution
1
Set build mode to Release
Project → Project Options → Compiler Options → Build Mode → Release
2
Configure optimization
- Optimization level: -O3
- Smart linking: Enabled
- Strip symbols: Enabled (for smaller executable)
3
Build executable
4
Include required libraries
Linux:
- GTK2/GTK3 libraries (usually pre-installed)
- Database client libraries if needed
- Application bundle with frameworks
- Usually no extra DLLs needed (static linking)
See Also
VCL Framework
Native Windows VCL implementation
FireMonkey Framework
Cross-platform FMX alternative
Data Binding
Connect to datasets and other data sources
Cell Editing
Editor controls and customization
