Overview
TheTGridSelection class controls how cells are selected and highlighted in a TeeGrid. It supports both single-cell selection and multi-cell range selection, with customizable visual formatting and behavior.
Class Hierarchy
Key Features
- Single-cell selection
- Multi-cell range selection
- Full-row selection mode
- Customizable selection appearance
- Separate formatting for focused and unfocused states
- Automatic scroll-to-view support
- Parent font inheritance
Properties
Column
Row
Range
Range.Enabled to True to activate range selection.
Example:
FullRow
True, selecting any cell highlights the entire row.
Default: False
Example:
ParentFont
True, the selection uses the parent grid’s font settings.
Default: True
ScrollToView
True, the grid automatically scrolls to make the selected cell visible.
Default: False
Example:
UnFocused
OnChange
Methods
Constructor Create
TGridSelection instance.
Parameters:
AChanged: Event handler called when selection changes
Assign
Source: The source object to copy from
Change
AColumn: The column to selectARow: The row index to select
Clear
GetColumns
Visible: The visible columns collectionAFrom: Returns the starting column indexATo: Returns the ending column index
InitFormat
IsEmpty
True if no cell is currently selected.
Returns: Boolean indicating if selection is empty
Example:
PaintColumn
AData: Rendering dataAColumn: The column to paintAFont: The font to useIsFocused: Whether the grid has focus
TryRange
AColumn: The column to extend toARow: The row to extend toY: The vertical position
TSelectionRange Class
TheTSelectionRange class defines a rectangular range of cells for multi-cell selection.
Properties
Enabled
False
FromColumn / ToColumn
FromRow / ToRow
-1 (no row selected)
Usage Examples
Single-Cell Selection
Multi-Cell Range Selection
Customizing Selection Appearance
Full-Row Selection
Handling Selection Changes
Programmatic Selection with Navigation
Important Notes
Selection only applies to columns that have their
Selectable property set to True.See Also
- TGridBands - Grid bands for headers and footers
- TGridEditing - Cell editing configuration
- TIndicator - Grid row indicator column
