Skip to main content

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

The TColumn class (defined in Tee.Grid.Columns.pas) represents a single column in the grid.

Core Properties

TColumnHeader
Configures the column header display:
  • Text: Header caption
  • ParentFormat: Inherit formatting from parent
  • TextAlignment: Automatic or custom alignment
  • Format: Brush, stroke, font, and margins
TColumnWidth
Column width configuration:
  • Automatic: Auto-size based on content
  • Value: Fixed pixel width
  • Percent: Percentage of available width (e.g., 25 for 25%)
TColumns
Collection of sub-columns for hierarchical layouts. When a column has items, it acts as a container/group for its children.
Boolean
default:"True"
Controls visibility of sub-columns. When False, child columns are hidden.
Boolean
default:"True"
Controls column visibility. Hidden columns don’t render or occupy space.
Boolean
default:"False"
Prevents editing for this column. Users can select but not modify cell values.
Boolean
default:"True"
Controls whether cells in this column can be selected.

Formatting Properties

TFormat
Visual formatting:
  • Brush: Background fill
  • Stroke: Border and lines
  • Font: Text appearance
TDataFormat
Data-specific formatting:
  • Float: Number format string (default: “0.###”)
  • Date: Date format string
  • DateTime: DateTime format string
  • Time: Time format string
TTextAlign
Horizontal and vertical text alignment within cells:
TColumnTextAlign
  • Automatic: Right-align numbers, left-align text
  • Custom: Use explicitly set TextAlign values
TMargins
Cell content padding (Left, Top, Right, Bottom).

Advanced Features

TRender
Custom renderer for cell content. Override default text rendering with:
  • Progress bars
  • Images
  • Buttons
  • Charts
  • Custom graphics
TColumnLocked
Pin columns:
  • None: Normal scrolling
  • Left: Fixed on left side
  • Right: Fixed on right side
Boolean
default:"True"
When True, inherits formatting from parent column (if nested) or grid cells.
TObject
User-defined object reference. TeeGrid uses this internally to link columns to data fields/properties.
TClass
Custom editor control class for cell editing. Override default TEdit behavior.

TColumns Collection

The TColumns class manages a collection of TColumn objects.

Creating Columns

Column Spacing

Hierarchical Columns

TeeGrid supports nested columns for grouped headers and complex layouts:
Visual Result:

Working with Hierarchy

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 class TVisibleColumns 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

  • Minimize custom painting in OnPaint - it’s called for every visible cell
  • Use ParentFormat := True when possible to reduce memory
  • Avoid complex calculations in data format strings
  • 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
  • Limit nesting to 2-3 levels for readability
  • Use meaningful group names
  • Consider whether hierarchy adds value vs complexity
  • 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