Skip to main content

Overview

The TGridSelection 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

The currently selected column. Example:

Row

The currently selected row index (zero-based). Example:

Range

Configures multi-cell range selection. Set Range.Enabled to True to activate range selection. Example:

FullRow

When True, selecting any cell highlights the entire row. Default: False Example:

ParentFont

When True, the selection uses the parent grid’s font settings. Default: True

ScrollToView

When True, the grid automatically scrolls to make the selected cell visible. Default: False Example:

UnFocused

Defines the visual appearance of the selection when the grid doesn’t have focus. Example:

OnChange

Event triggered when the selection changes. Example:

Methods

Constructor Create

Creates a new TGridSelection instance. Parameters:
  • AChanged: Event handler called when selection changes

Assign

Copies selection properties from another object. Parameters:
  • Source: The source object to copy from

Change

Changes the current selection to the specified column and row. Parameters:
  • AColumn: The column to select
  • ARow: The row index to select
Example:

Clear

Clears the current selection. Example:

GetColumns

Retrieves the column indices for the current selection range. Parameters:
  • Visible: The visible columns collection
  • AFrom: Returns the starting column index
  • ATo: Returns the ending column index

InitFormat

Initializes the selection format with default values.

IsEmpty

Returns True if no cell is currently selected. Returns: Boolean indicating if selection is empty Example:

PaintColumn

Paints the selection highlight for a specific column. Parameters:
  • AData: Rendering data
  • AColumn: The column to paint
  • AFont: The font to use
  • IsFocused: Whether the grid has focus

TryRange

Attempts to extend the selection range to include the specified cell. Parameters:
  • AColumn: The column to extend to
  • ARow: The row to extend to
  • Y: The vertical position

TSelectionRange Class

The TSelectionRange class defines a rectangular range of cells for multi-cell selection.

Properties

Enabled

Enables or disables range selection mode. Default: False

FromColumn / ToColumn

The starting and ending columns of the selection range.

FromRow / ToRow

The starting and ending row indices of the selection range. Default: -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.
When using range selection, ensure that Range.Enabled is set to True before setting the range boundaries.

See Also