Overview
TeeGrid’s column system is built on a hierarchical model where columns can contain sub-columns, enabling sophisticated layouts like grouped headers and multi-level column organization.TColumn Class
TheTColumn class (defined in Tee.Grid.Columns.pas) represents a single column in the grid.
Core Properties
Configures the column header display:
Text: Header captionParentFormat: Inherit formatting from parentTextAlignment: Automatic or custom alignmentFormat: Brush, stroke, font, and margins
Column width configuration:
Automatic: Auto-size based on contentValue: Fixed pixel widthPercent: Percentage of available width (e.g., 25 for 25%)
Collection of sub-columns for hierarchical layouts. When a column has items, it acts as a container/group for its children.
Controls visibility of sub-columns. When
False, child columns are hidden.Controls column visibility. Hidden columns don’t render or occupy space.
Prevents editing for this column. Users can select but not modify cell values.
Controls whether cells in this column can be selected.
Formatting Properties
Visual formatting:
Brush: Background fillStroke: Border and linesFont: Text appearance
Data-specific formatting:
Float: Number format string (default: “0.###”)Date: Date format stringDateTime: DateTime format stringTime: Time format string
Horizontal and vertical text alignment within cells:
Automatic: Right-align numbers, left-align textCustom: Use explicitly set TextAlign values
Cell content padding (Left, Top, Right, Bottom).
Advanced Features
Custom renderer for cell content. Override default text rendering with:
- Progress bars
- Images
- Buttons
- Charts
- Custom graphics
Pin columns:
None: Normal scrollingLeft: Fixed on left sideRight: Fixed on right side
When
True, inherits formatting from parent column (if nested) or grid cells.User-defined object reference. TeeGrid uses this internally to link columns to data fields/properties.
Custom editor control class for cell editing. Override default TEdit behavior.
TColumns Collection
TheTColumns class manages a collection of TColumn objects.
Creating Columns
Column Spacing
Hierarchical Columns
TeeGrid supports nested columns for grouped headers and complex layouts:Working with Hierarchy
- Expand/Collapse
- Level Information
Column Width Management
TeeGrid provides flexible width calculation:Automatic Width
Fixed Width
Percentage Width
Mixed Widths
Locked Columns
Freeze columns at the left or right edge:Custom Column Events
OnPaint Event
Customize cell painting on a per-column basis:Visible Columns
Internal helper classTVisibleColumns tracks currently visible columns:
Indicator Column
Special column showing row state:Column Reordering
Columns can be moved programmatically:Data Type Alignment
Automatic alignment based on data types:Column Iteration
Column Best Practices
Performance
Performance
- Minimize custom painting in OnPaint - it’s called for every visible cell
- Use
ParentFormat := Truewhen possible to reduce memory - Avoid complex calculations in data format strings
Usability
Usability
- Use descriptive header text
- Set appropriate column widths for content type
- Consider locked columns for key fields
- Make calculated/read-only columns obviously non-editable
Hierarchy
Hierarchy
- Limit nesting to 2-3 levels for readability
- Use meaningful group names
- Consider whether hierarchy adds value vs complexity
Formatting
Formatting
- Use consistent date/number formats across similar columns
- Align numbers to the right for easy comparison
- Apply data formats at column level, not in AsString()
Common Patterns
Calculated Column
Image Column
Boolean Column (Checkboxes)
Next Steps
Custom Renderers
Create custom column rendering
Data Binding
Learn how columns connect to data
Locked Columns
Deep dive into column freezing
TColumn API
Complete API reference
