TFormat, TTextFormat, TBrush, TStroke, and TFont classes. You can customize colors, borders, fonts, and gradients for individual columns, cells, headers, and the entire grid.
Understanding Format Classes
TFormat
The base formatting class that combines brush (fill) and stroke (border) properties:TTextFormat
ExtendsTFormat to include font properties for text rendering:
Styling Grid Cells
Column-Level Formatting
Apply custom formatting to an entire column:Conditional Cell Formatting
Use theOnPaint event to apply formatting based on cell values:
Alternating Row Colors
Style odd and even rows differently:Colors and Opacity
TeeGrid usesTColor (an alias for TAlphaColor in modern Delphi) which supports opacity:
Gradients
Apply gradient fills to backgrounds:Gradient Directions
Stroke Styles
Customize borders and lines with different stroke styles:Stroke End and Join Styles
Font Styles
Configure text appearance:Margins and Padding
Control spacing inside cells:Complete Styling Example
Here’s a comprehensive example that styles a financial data grid:Best Practices
Use ParentFormat wisely
Use ParentFormat wisely
When
ParentFormat := True, the column inherits formatting from TeeGrid.Cells.Format. Set to False only when you need column-specific styling.Performance considerations
Performance considerations
Avoid complex calculations in
OnPaint events as they’re called for every visible cell. Cache computed values when possible.Color contrast
Color contrast
Ensure sufficient contrast between text and background colors for readability. Test with different themes and monitor settings.
Consistent styling
Consistent styling
Define a consistent color scheme across your application. Consider creating reusable style presets.
Related Topics
Custom Renderers
Create custom cell renderers for specialized content
Themes
Apply predefined themes to your grid
Headers and Footers
Style grid headers and footer bands
TFormat API
Complete API reference for formatting classes
