Understanding Renders
A renderer is a class derived fromTRender that controls how cell content is painted. The base rendering hierarchy:
TRender— Base class withPaintmethodTFormatRender— Adds format and bordersTTextRender— Adds text rendering with margins and alignmentTVisibleTextRender— Adds visibility control
Built-in Renderers
Boolean Renderer (Checkboxes)
Display boolean values as checkboxes:TBooleanRenderStyle.Check— Shows checkbox with checkmarkTBooleanRenderStyle.Text— Shows “True” or “False” as text
Progress Bar Renderer
Display numeric values as progress bars:Expander Renderer
Create expandable/collapsible cells for hierarchical data:Password Renderer
Mask text content for password fields:Creating Custom Renderers
Basic Custom Renderer
Create a simple custom renderer by overriding thePaint method:
Advanced Custom Renderer with Graphics
Draw custom graphics in cells:Image Renderer
Display images in cells:Render Data Structure
TheTRenderData record passed to Paint contains:
Text Rendering Options
Text Alignment
Control how text is aligned within cells:Text Trimming
Handle text overflow:Borders and Decorations
Custom Borders
Add borders to individual sides of cells:Hit Testing
Implement custom hit testing for interactive renderers:Complete Example: Multi-State Icon Renderer
Best Practices
Keep Paint methods efficient
Keep Paint methods efficient
The
Paint method is called for every visible cell. Avoid heavy calculations, file I/O, or object creation inside Paint. Cache resources when possible.Use inherited Paint wisely
Use inherited Paint wisely
Call
inherited Paint(AData) when you want default rendering before or after your custom painting. Don’t call it if you’re completely replacing the default rendering.Respect cell boundaries
Respect cell boundaries
Always draw within
AData.Bounds. Drawing outside these bounds can cause visual artifacts and overlap with adjacent cells.Handle empty data gracefully
Handle empty data gracefully
Check if data is empty or invalid before rendering. Use
AData.IsEmpty or validate the data format.Related Topics
Styling
Configure colors, fonts, and borders
TRender API
Complete API reference for render classes
TPainter API
Drawing interface for custom rendering
Custom Editors
Create custom cell editors
