Classes for displaying tabular data as a series of rows and columns.

grids.pas contains classes, types, constants, variables, and routines used to implement grid controls for the Lazarus Component Library (LCL). Classes include:

  • TVirtualGrid
  • TCustomGrid
  • TDrawGrid
  • TStringGrid

Original author: Jesus Reyes Aguilar (jesusrmx@yahoo.com.mx) [2002]

Current revision level for the grids.pas file.
1
Initial revision
2
Introduced goSmoothScroll grid option
3
Introduced Col/Row FixedAttr and NormalAttr
Lazarus message for setting the value in a grid edit control. Lazarus message for getting the value in a grid edit control. Lazarus message for setting the grid for an edit control. Lazarus message for setting the bounds for a grid edit control. Lazarus message for selecting the content in a grid edit control. Lazarus message for setting the edit mask used in a grid edit control. Lazarus message for setting the position of a grid edit control. Lazarus message sent when the grid can display its editing controls. Lazarus message used to get the grid for an editing control. Represents the auto-size editor option in a grid message. Represents the hook key down editor option in a grid message. Represents the hook key press editor option in a grid message. Represents the hook key up editor option in a grid message. Represents the select all content editor option in a grid message. Represents the implemented editor option in a grid message. Default width for columns in a grid control.

DEFCOLWIDTH is a constant used as the default width for columns in a grid control. The value for the constant is 64 (pixels). DEFCOLWIDTH is used when getting the value for the DefColWidth in TCustomGrid.

Default width for edit control buttons in a grid.

DEFBUTTONWIDTH is a constant that contains the default width for the button displayed in a grid cell editor. The value for the constant is 25 (pixels). DEFBUTTONWIDTH is used when setting the bounds for TButtonCellEditor controls.

Default padding used for title images displayed in a grid.

DEFIMAGEPADDING is a constant which contains the padding added to images displayed in the fixed title area for grid controls. The value for the constant is 2 (pixels). DEFIMAGEPADDING is used in methods like TCustomGrid.DrawColumnTitleImage and TCustomStringGrid.AutoAdjustColumn.

Default value used as the minimum grid column size. Default value used as the maximum grid column size. Default value for SizePriority property in a grid column. Exception raised when an error has occurred in a Grid class.

Used mainly when a row or a column position is invalid for a grid control.

Represents grid option values available for grid controls.

TGridOption is an enumerated type with values that represent grid options available in LCL grid controls. Values from TGridOption are stored in a TGridOptions set type to indicate that the grid feature or behavior is enabled.

Values from TGridOption are stored in the DefaultGridOptions constant which defines the default set of options for LCL grid controls.

Shows vertical lines around fixed cells. Shows horizontal lines around fixed cells. Show vertical lines. Show horizontal lines. Enables range selection for grid cells. Enables drawing using the SelectedColor for selected cell(s) and FocusColor for the focus rectangle (or rubber band). Allow user to change row height. Allow user to change column width. Enables moving the position of an entire row in a grid. Enables moving the position of an entire column in a grid. Allows editing in grid cells. Automatically add new rows. Does not add rows if the last cell is empty and goAutoAddRowsSkipContentCheck is not set. Controls Tab key behavior in the grid. When enabled, the Tab key changes the active cell within the grid. When omitted, the Tab key changes to the next active control. Select the whole row instead of only one cell. Always shows the cell editor. If not set, the user has to enter edit mode by data characters for the cell, or by pressing the F2 key. Enables tracking of the thumb position in grid scroll bars. Enable cell extent calculations. User can see focused cell on goRowSelect. Enables using double click on a column border (on headers) to resize a column. Enables smooth scrolling mode. Default is pixel scroll. Causes row numbers to be displayed in the first column in FixedCols. The displayed row numbers starts with 1. The row number is displayed when no text has been directly assigned to the fixed cell. Keeps focused cell visible while scrolling. Header cells change look when mouse is over them. Header cells looks pushed when clicked. Setting a grid selection also moves the cell cursor. Enables resizing of fixed columns. When enabled, selecting a partially visible cell will not scroll the grid content. Show individual cell hints. Requires the ShowHint property to be set to True. If set, the Hint will be ignored. Instead the OnGetCellHint event will be called for each cell. Truncates cell hints when they are longer than the cell content. Shows an Ellipsis (...) at the end of truncated cell hints. Adds a row if last row is empty. goAutoAddRows must also be set. Otherwise this option does not take effect. Highlights the current Row in a grid control. Set type used to store enabled grid options.

TGridOptions is a set type used to store values from the TGridOption enumeration. The features or behaviors in TGridOption are enabled when their enumeration values are included in the set. TGridOptions is the type used for the TCustomGrid.Options property.

Represents grid options introduced in Version 2 (or higher) of grid controls.

TGridOption2 is the type used to implement the Options2 property in TCustomGrid and descendent classes.

Modified in version 2.4 to include goEditorParentColor and goEditorParentFont options.
Allows scrolling to last column (so that last column can be leftcol). Allows scrolling to last row (so the last row can also be TopRow). Sets the color in a cell editor to the color for the parent control. Sets the font in a cell editor to the font for the parent control. Set type used to store enabled grid options from the TGridOption2 enumeration.

TGridOptions2 is the type used to implement the Options2 property in TCustomGrid. The features represented by the values in the set are enabled in a grid control when present.

See TGridOption2 for the available enumeration values and their meanings.

Represents the save options available for LCL grid controls.

TGridSaveOptions is an enumerated type with values for the save options that can be enabled for the TCustomGrid control and its descendants.

TGridSaveOptions values are stored in the TSaveOptions set type, and used to implement the SaveOptions property in TCustomGrid. When a value is present in the set, it indicates that the option is enabled, and causes the affected properties to be stored in the SaveContent method for the grid control.

Enables saving grid structure (col / row count and Options). Enables saving grid attributes (Font, Brush, TextStyle). Enables saving Grid content (Text in TStringGrid). Enables saving the Grid cursor and selection position. Set type used to store TGridSaveOptions values.

TSaveOptions is a set type used to store zero or more values from the TGridSaveOptions enumeration.

When a TGridSaveOptions value is present in the set, it indicates that the option is enabled. This in turn causes the affected properties to be stored in the SaveContent method for the grid control.

TSaveOptions is the type used to implement the SaveOptions property in TCustomGrid.

Enumeration with Grid draw state values.

TGridDrawState is an enumeration with values that represent grid drawing states for a grid control. Values in TGridDrawState indicate the display attributes applied to a row, a column, or an individual cell in a grid control.

TGridDrawState arguments are passed to event handlers and methods in TCustomGrid.

Drawn in its Selected state. Drawn in its Focused state. Drawn using the Fixed cell colors. Drawn using the Hot or hovered display attributes. Drawn in a Pushed state. Drawn using the row highlighting color. Enumerated type with grid state values.

TGridState is an enumerated type with values that reflect the state in a grid control. TGridState values represent actions performed using a grid control, rather than the display state for rows, columns, and/or cells.

TCustomGrid maintains an internal TGridState member used to track the state for the grid control. Methods in TCustomGrid cause the value in the member to be read or updated to reflect the request and/or completion of an action in the grid control.

Use the TCustomGrid.Options and TCustomGrid.Options2 properties to determine if specific features or behaviors are enabled for a grid control.

Normal state for the grid when navigation or editing can be performed. Grid is selecting a row, column, or cell after keyboard or mouse activity. Grid is resizing a row. Grid is resizing a column. Grid is moving or dragging a row. Grid is moving or dragging a column. A fixed header cell has been clicked in the Grid. A button in a column has been clicked. Enumerated type with values which represent the zones or areas on a grid control.

TGridZone is an enumeration type with values representing zones in a grid control which are monitored to determine activity and subsequent changes in the control state.

Values from TGridZone are stored in the TGridZoneSet type, and used to implement properties in TCustomGrid like:

  • HeaderHotZones
  • HeaderPushZones

The type is also passed as an argument to the Clean method in TCustomStringGrid.

Area normally used for cell data (not fixed row or column headers). Area used for fixed column headers Area used for fixed row headers Area for fixed cells (where both the column and the row are fixed). Area not valid for grid cells. Set type used to store TGridZone enumeration values.

TGridZoneSet is a set type used to store zero or more values from the TGridZone enumeration.

TGridZoneSet is the type used to implement properties in TCustomGrid like:

  • HeaderHotZones
  • HeaderPushZones

It is also passed as an argument to the Clean method in TCustomStringGrid to indicate the area where the operation is applied.

Enumerated type with values controlling grid auto advance behavior.

TAutoAdvance is an enumerated type with values that represent the auto advance behaviors available in a grid control. TAutoAdvance is the type used to represent the AutoAdvance and TabAdvance properties in TCustomGrid.

Auto advance is not enabled. Advances down to the next row in the grid. Advances to the right (next cell) in the grid. Advances to the left (previous cell) in the grid. Advances to the right and then to the next row. Advances to the left and then to the next row. Advances to the right and then to the previous row. Advances to the left and then to the previous row. Enumerated type with the Range selection mode used in a grid control.

TRangeSelectMode is the type used to implement the RangeSelectMode property in TCustomGrid.

Allows range selection for a single range in a grid. Allows range selection for multiple ranges in a grid. Not used in the current LCL implementation.

Not used in the current LCL implementation.

Enumeration with cell editor types available in a grid control.

TColumnButtonStyle is an enumerated type with values that represent the different cell editor types available in a grid control. TColumnButtonStyle is the type used for the TGridColumn.ButtonStyle property, and passed as an argument when an editor is requested for a column definition. It is also used when the TCustomGrid.GetDefaultEditor method is called to get the default cell editor for a given column.

Button style is automatically determined by the grid control. Results in a TStringCellEditor being used for the cell. Button style with an Ellipsis (...) is displayed as the cell editor. Results in a TCompositeCellEditor being used for the cell. Indicates no editor is required for a cell. Indicates a Pick List is used in the grid column. Results in a TPickListCellEditor being used for the cell. Indicates a check box is displayed as the editor for the grid column. Indicates a cell editor with a Button is used in the grid column. Causes a TButtonCellEditor to be created. Indicates a button, centered in the cell, is used in the grid column. Enumeration with values that control the display style for fixed title cells.

TTitleStyle is an enumerated type with values that determine the drawing style used for fixed title cells in a grid. TTitleStyle is the type used to implement the TCustomGrid.TitleStyle property, and used in the implementation of the TCustomGrid.DrawCellGrid method.

Titles are displayed using the Lazarus drawing style. Titles are displayed using the standard drawing style (higher contrast). Titles are displayed using the drawing style Native to the OS or platform. Represents state flags used in a grid control.

TGridFlagsOption is an enumerated type with values which reflect temporal state changes in a grid control. Values from TGridFlagsOption are stored at run-time in the TGridFlags set type used for the TCustomGrid.GridFlags property.

Indicates a cell is locked during a cell editor update. Indicates a selection needs to be active prior to mouse down or move actions. Indicates a Tab key can be applied to focus the next cell in the grid. Indicates if Shift+Tab can be used to select the previous cell in the grid. Indicates visible changes to row or column sizes can be applied to the grid. Indicates columns in the grid are locked and cannot be reordered. Indicates editing using a cell editor has been completed. Indicates a row or column sizing action is in effect. Indicates the grid is being redrawn. Indicates the grid is updating its size. Indicates the client rectangle for the grid has changed. Indicates a cell editor is being prepared for a newly selected cell in the grid. Indicates the visibility of scroll bar(s) has been changed for a grid. Set type used to store TGridFlagsOption enumeration values.

TGridFlags is a set type used to store TGridFlagsOption enumeration values. TGridFlags is the type used to implement the TCustomGrid.GridFlags property.

Enumerated type with sort orders supported in a grid control.

TSortOrder is an enumerated type with values for the sort orders supported in a grid control. TSortOrder is the type used to implement the TCustomGrid.SortOrder property.

Rows are sorted such that the column is in ascending order. Rows are sorted such that the column is in descending order. Indicates how accelerator keys in column titles are handled for a grid control.

TPrefixOption is the type used to implement the PrefixOption property in TGridColumnTitle.

Accelerator keys are ignored in the grid column. Accelerator keys emulate a mouse click on the column title. Enumerated type with values that control mouse wheel operation in a grid control.

TMouseWheelOption is the type used to implement the MouseWheelOption property in TCustomGrid.

Causes the mouse wheel to move the cursor on the screen. Causes the mouse wheel to scroll the content in the grid. Represents the cell hint display priorities.

A grid control can display three types of hint: the default hint (in the Hint property), individual cell hints (using the OnCellHint event), and hints for truncated cells. TCellHintPriority determines how the hint text is determined when multiple hint text values are available for display.

TCellHintPriority is the type used to implement the CellHintPriority property in TCustomGrid.

Uses all hints (control and cell hints) including short and long display text values. Uses all hints except the default hint for the grid control. Uses the truncated cell hint text. Identifies the action performed for cell content.

TCellProcessType is an enumerated type with values that identify the action performed for the content in a grid cell. Values in the enumeration indicate whether cell content is copied or pasted in event handlers. TCellProcessType arguments are passed to the TCustomStringGrid.OnCellProcess event handler.

Copies the content in a grid cell. Pastes content into the grid cell. All save options available for grid controls.

soAll is a TSaveOptions constant with the set representing all of the TGridSaveOptions values available for a LCL grid control.

Set with the default grid options enabled for instances of the grid control.

DefaultGridOptions is used as the default value for the Options property in TCustomGrid.

Default grid options enabled for version 2 of the grid control.

DefaultGridOptions2 is used as the default value for the Options2 property in TCustomGrid.

Default spacing around rubber band rectangles. Default padding for the content in grid cells.

Cell padding is the amount of space added around cell values and hints drawn for a grid control. The value represents the number of pixels added to the boundaries at the default display density (96 PPI). The value may be scaled and stored in the varCellPadding variable when a new instance of a grid control is created. varCellPadding contains the padding value actually applied to the values and hints in the control.

Minimum proximity to row or column borders for resizing operations. Default padding for the rubber banding rectangle in grid cells. Default padding for the content in grid cells.

Cell padding is the amount of space added around cell values and hints drawn for a grid control. The value represents the number of pixels added to the boundaries at the default display density (96 PPI). The value may be scaled and stored in the varCellPadding variable when a new instance of a grid control is created. varCellPadding contains the padding value actually applied to the values and hints in the control.

Proximity threshold for a mouse click near a column boundary.

Used during grid column resizing when fixed column sizing has been enabled.

Pointer to a TCellProps type. Contains attributes, data, and text for grid cells. Attributes for a grid cell. Data for a grid cell. Display text for a grid cell. Pointer to a TColRowProps type. Contains the size and display attributes for a column or row in a grid. Not used in the current implementation. Not used in the current implementation. Not used in the current implementation. Pointer to a TGridMessage type. Contains a LCL message and its auxiliary values.

TGridMessage is a record type with members representing an LCL message passed to cell editors in a string grid. It is passed as an argument to TStringCellEditor methods (msg_SetMask, msg_GetGrid, et. al.) which handle and apply a specific LCL message.

The LCL message value. Grid for the LCL message. Grid column for the LCL message. Grid row for the LCL message. Cell value for the LCL message. Rectangle coordinates for the LCL message. Options for the LCL message. Implements the default editor for cells in TCustomGrid.

TStringCellEditor is a TCustomMaskEdit descendant that implements the default editor for cells in TCustomGrid. TStringCellEditor contains internal members used to reference its Grid control, and to access the row and column numbers for the underlying grid cell. TStringCellEditor also implements methods needed for LCL message passing using TGridMessage. An event handler is also published to perform actions needed when editing has been completed in the cell editor.

TCustomMaskEdit
Implements the message processing loop for the cell editor control.

WndProc is an overridden method in TStringCellEditor which implements the message processing loop for the cell editor control.

WndProc ensures that the column for the cell in the grid control is not marked as read-only when handling cut (LM_CUT), paste (LM_PASTE), and clear (LM_CLEAR) messages in TheMessage argument. No actions are performed in the method when the EditorIsReadOnly method in the associated grid control returns True.

If the grid control has not been assigned, or TheMessage contains a different message identifier, the inherited method in TCustomEdit is called to handle the specified message.

TCustomGrid.EditorIsReadOnly TCustomEdit.WndProc
LCL message handled in the method. Performs actions needed when the value in the cell editor has been changed.

Change is an overridden method in TStringCellEditor used to perform actions needed to apply the new value in the cell editor to the associated grid control.

Change calls the inherited method on entry to perform a change notification message for the control, and to signal any assigned OnChange event handler(s) in the component hierarchy. Please note that the OnChange event is suppressed when the initial value for cell editor is assigned; the handler is signalled when the value has been modified using the cell editor control.

If the associated grid control has been assigned, and the cell editor is Visible, the EditorTextChanged method in the grid control is called to apply the value in Text to the current cell in the grid.

TCustomMaskEdit.Change TCustomEdit.OnChange TControl.Visible
Handles a key down event for the control.

KeyDown is an overridden method in TStringCellEditor which handles a key down event for the cell editor. It calls the inherited method on entry to handle the virtual key codes normally supported in the TCustomMaskEdit control. It extends the inherited method to provide support for the following keys:

F2
Allows the grid control to handle the key. If editing is not enabled for the control, the current text selection in the editor is cleared. When editing is enabled and FastEditing is True, SelectAll is called select all of the content in Text.
Delete, Backspace
Discards the value in key when the grid control or the column is marked as read-only. Otherwise, the key is forwarded to the EditorKeyDown method in the grid control.
Cursor Up, Cursor Down
Forwards the key to the KeyDown method in the grid control.
Cursor Left, Cursor Right
Handles cell navigation for the grid control, and caret position changes for the cell editor. Uses SelStart to determine the position for the selected text in the editor. Forwards the key to the grid control or its Editor control as needed for the current selection.
Escape
Allows the grid control to handle the key. When not handled, the unedited value is restored to the cell and the EditorHide method for the grid is called to hide the editor control.

Other unhandled key codes are forwarded to the EditKeyDown method for the grid control.

TCustomMaskEdit.KeyDown
Key code handled in the method. Shift, Ctrl, or Alt modifier the key code. Handles the message used to set the EditMask for the cell editor. Grid message for the control. Handles the message used to set the Text and caret position in the cell editor. Grid message for the control. Handles the message used to store the coordinates and text for the cell to the specified grid message. Grid message for the control. Handles the message used to store the associated grid and options for the cell editor. Grid message for the control. Calls the SelectAll method when the GM_SELCTALL message is received. Grid message for the control. Stores the column and row numbers from the specified message to the cell editor. Grid message for the control. Stores the associated grid control and its options to the specified message. Grid message for the control. Constructor for the class instance.

Create is the overridden constructor for the class instance. Create calls the inherited constructor using the value in AOwner as an argument. Create sets the value in the AutoSize property to False.

TCustomEdit.AutoSize
Owner of the class instance. Performs actions needed when the cell editor has finished editing the value in a cell.

EditingDone is an overridden procedure used to perform actions required when the cell editor has finished editing the value in a cell. EditingDone calls the inherited method, and calls the EditingDone method in the attached Grid control (when assigned) for the cell editor.

The editor used for button-style cells in a grid.

TButtonCellEditor is a TButton descendant which implements a grid cell editor which uses a button to activate the editor control. TButtonCellEditor maintains internal member variables for the TCustomGrid hosting the editor control. The row and column numbers for the underlying cell in editor control are available in the Row and Col properties. TButtonCellEditor includes methods used to perform LCL message passing using a TGridMessage message type.

Handles the message which stores the associated grid and options used in the cell editor. Grid message for the cell editor. Handles the message which sets the bounds for the cell rectangle in the cell editor.

Adjusts the rectangle for the "rubber band" displayed around the cell, and ensures that space is reserved for the button displayed for the editor control.

Grid message for the cell editor. Handles the message used to save the column and row number to the cell editor control. Grid message for the cell editor. Handles the message which sets the width for the editor when it is ready to edit in the cell. LCL message for the grid control. Handles the message used to get the grid control and options for the cell editor. LCL message for the grid control. Column number for the cell editor.

Col is a public read-only Integer property which contains the column number for the cell hosting the editor control.

Use Row to access the row number for the cell hosting the editor control.

Row number for the cell editor.

Row is a public read-only Integer property which contains the row number for the cell hosting the editor control.

Use Col to access the column number for the cell hosting the editor control.

Implements a cell editor control which displays a pick list.

TPickListCellEditor is a TCustomComboBox descendant which implements a cell editor control that displays a pick list. TPickListCellEditor provides overridden methods to alter the behavior of the TCustomComboBox ancestor.

TPickListCellEditor has an internal member used to store the TCustomGrid for the cell editor. In addition, the Row and Column numbers for the underlying cell are stored in internal members. TPickListCellEditor provides methods needed to implement LCL message passing using the TGridMessage message type.

Implements the message processing loop for the cell editor.

WndProc is an overridden method in TPickListCellEditor. It ensures that an LM_KILLFOCUS message in TheMessage is ignored when the cell editor temporarily looses focus during an update to the control.

WndProc calls the inherited method prior to exit to respond to other window, mouse, and keyboard messages.

TLMessage TWinControl.WndProc
LCL message examined and handled in the method. Handles a key down message for the cell editor.

KeyDown is an overridden method in TPickListCellEditor. It extends the inherited method to ensure that specific key codes are applied to the grid or the editor control as needed.

KeyDown calls the inherited method on entry to handle Tab, Return, and Escape key code in the manner needed for the TCustomComboBox ancestor. It adds support for the following keys:

F2
Clears the selection length and moves the caret position to the end of the Text in the cell editor.
Return
Calls the EditorkeyDown method for the grid control, discards the key code, and closes the drop down in the editor control when it is expanded.
Delete
Discards the key code if the grid control or the editor cannot be modified.
Cursor Up, Cursor Down
Calls the KeyDown method for the grid control if the drop down is not expanded for the cell editor.
Cursor Left, Cursor Right
Handles cell navigation for the grid control, and caret position changes for the cell editor. Uses SelStart to determine the position for the selected text in the editor. Forwards the key to the grid control or its Editor control as needed for the current selection.
Home, End
Ignored in the key down handler.
Escape
Allows the grid control to handle the key. When not handled, the unedited value is restored to the cell and the EditorHide method for the grid is called to hide the editor control.

Other unhandled key codes are forwarded to the EditKeyDown method for the grid control.

TCustomComboBox.KeyDown
Key code for the key down event. Shift, Alt, or Ctrl modifier for the key down event. Applies a value selected from the pick list to the grid and signals its OnPickListSelect event handler.

Select is an overridden method in TPickListCellEditor used to apply the value selected from the drop-down list in the editor to a cell in the grid.

When the associated grid for the cell editor has been assigned, its EditorTextChanged method is called to apply the Text in the editor to the cell. The PickListItemSelected in the grid control is called to signal the OnPickListSelect event handler (when assigned).

Select calls the inherited method prior to exit to signal the OnSelect event handler in the ancestor control (TCustomComboBox).

TCustomComboBox.Text TCustomComboBox.Select TCustomComboBox.OnSelect
Notifies the Grid control when the value for the cell editor has been changed.

Change is an overridden method used to perform actions needed when the value for the control has been changed. In TPickListCellEditor, it ensures that the grid control is notified when the value in the cell editor has been changed.

Changed calls the inherited method to signal the OnChange event handler (when assigned).

TCustomComboBox.Change
Handles the message used to store the coordinates and text for the cell to the specified grid message. TCustomComboBox.Text LCL message for the grid control. Handles the message used to store the associated grid and options for the cell editor. LCL message for the grid control. Handles the message used to set the Text and caret position in the cell editor. LCL message for the grid control. Stores the column and row numbers from the specified message to the cell editor. LCL message for the grid control. Stores the associated grid control and its options to the specified message. LCL message for the grid control. Performs actions needed to synchronize the grid and the editor when editing has been completed in the cell editor.

EditingDone is an overridden method in TPickListCellEditor. It calls the inherited method on entry to signal the OnEditingDone event handler (when assigned). The EditingDone method in the associated grid control is called when the editor control is not already visible.

TControl.EditingDone TControl.OnEditingDone
Represents one of the editors used in a TCompositeCellEditor instance.

TEditorItem is a record type used to maintain information about an editor control used a TCompositeCellEditor instance. Members in the record identify the editor control, its alignment, and a flag which indicates if the editor control is active.

TEditorItem instances are allocated when the AddEditor method in TCompositeCellEditor is called.

The Editor to be used for this item. Alignment for the editor relative to the other controls in the composite editor. True if Editor is the active control for a composite cell editor. Implements a composite cell editor with combines one or more of the predefined cell editors types.

TCompositeCellEditor is a TCustomControl descendant which implements a cell editor composed of one or more of the cell editor types, such as:

  • TStringCellEditor
  • TButtonCellEditor

Editor controls of a specific type can be added to the class instance using the AddEditor method.

Use MaxLength to set the maximum number of characters allowed in the editor control derived from TCustomEdit in the composite editor.

Use ActiveControl to access the editor which is the focused control for the composite cell editor.

TCompositeCellEditor is the type used to implement the string cell editor in TCustomGrid / TGrid which includes a button to signal the OnEditButtonClick event for the grid control.

TCustomControl
Performs actions to handle a key press events for a UTF-8-encoded character.

DoUTF8KeyPress is an overridden method in TCompositeCellEditor. It calls the inherited method on entry to allow the key press to be previewed in Parent forms, or handled by the design surface at design-time. If the value in UTF8Key is not handled in the ancestor, the character is sent to (and optionally handled by) the ActiveControl in the composite cell editor.

The return value is True if the character in UTF8Key is handled in the method.

TWinControl.DoUTF8KeyPress TCustomForm.KeyPreview
True if the key press is handled in the message. UTF-8-encoded character value examined in the method. Handles the message used to store the coordinates and text for the cell editor to the specified grid message.

The message is dispatched to each of the editor controls in the composite editor until one of them reports a modified value.

Grid message updated in the method. Handles the message used to store the associated grid and options for the cell editor.

The message is dispatched to each of the editor controls in the composite editor.

Grid message examined in the method. Handles the message used to set the Text and caret position in the composite cell editor.

Dispatches the message to each of the editor controls in the composite cell editor.

Grid message processed in the method. Handles the message which sets the bounds for the cell rectangle in the cell editor.

Dispatches the message to each of the editor controls in the composite cell editor.

Grid message examined in the method. Handles the message used to set the EditMask for the cell editor.

Dispatches the message to each of the editor controls in the composite editor.

Grid message examined in the method. Calls the SelectAll method when the GM_SELCTALL message is received.

Dispatches the message to each of the editor controls in the composite editor.

Grid message examined in the method. Handles the CM_CONTROLCHANGE control message for the composite editor.

Sets the align property to alNone in the control at the address in Message when it is not the active control.

Control message with the values examined in the method. Stores the column and row numbers from the specified message to the cell editor.

Dispatches the message to each of the editor controls for the composite cell editor.

Grid message handled in the method. Handles the message used to store the grid control and editor options in the specified grid message. Grid message handled in the method. Gets the value for the ActiveControl property.

Gets the TWinControl-derived editor marked as the active control for the composite cell editor.

Value for the ActiveControl property Hides or displays editor controls when the value for the Visible property is changed.

Calls the inherited method on entry to signal assigned OnVisbleChanging event handlers in the control or form hierarchy. Updates the Visible property in each of the editor controls to match the property value in the TCompositeCellEditor instance. When displaying the editor controls, their Parent property is also updated to use the TCompositeCellEditor instance.

TControl.VisibleChanging
Sends the specified character to the active control and returns an integer status result.

Gets the active editor control, and sends the specified character to its widgetset class instance when the handle has been allocated. The return value is 1 if the character was sent to the widgetset class. The return value is 0 if the active control could not be determined, or its handle is not available.

UTF-8-encoded character applied in the method. Sets the value for the Color property.

Overridden in TCompositeCellEditor to ensure that the new color value is also applied to the ActiveControl (when assigned) in the composite editor.

TControl.Color
New value for the Color property. Implements message processing for the composite cell editor.

WndProc is an overridden method in TCompositeCellEditor. It ensures that a LM_CHAR message in TheMessage is handled for the control. The character argument in the message is passed to the active control using the SendChar method.

No additional actions are performed in the method if the character is handled by one of the editor controls in the composite editor. If the character is not handled, or the message has a message constant other than LM_CHAR, the inherited method (in TWinControl) is called.

#lcl.controls.TControl.WndProc
LCL message handled for the control. Destructor for the class instance.

Frees the internal list of TEditorItem instances, and calls the inherited destructor.

Sets the position for the editor in the composite control.

CustomAlignPosition is an overridden method in TCompositeCellEditor used to position and align the specified control in the composite editor. Currently there is only one aligned control in the composite editor; no provisions are made for calling CustomAlignInsertBefore() or sharing space with other editors in the control.

The variable arguments are updated in the method to reflect the new position and size for the specified control, including:

  • ANewLeft
  • ANewTop
  • ANewWidth
  • ANewHeight

CustomAlignPosition does not call the inherited method.

TWinControl.CustomAlignPosition
Editor control positioned and aligned in the method. New coordinate value derived in the method. New coordinate value derived in the method. New size value derived in the method. New size value derived in the method. Rectangle where the control is aligned. Not updated in the method. Not used in the current implementation. Adds the specified control to the composite cell editor using the given alignment and active state.

AddEditor increases the capacity for the internal array of TEditorItem instances used in the control. It stores the parameter values to the Editor, Align, and ActiveControl members in the new TEditorItem instance.

Editor control added to the composite cell editor. Alignment for the control relative to other editors. True if AEditor is the active control for the composite cell editor. Focuses the active control for the composite editor when it is Visible. TWinControl.SetFocus TControl.Visible Indicates if the composite cell editor and one of its editor controls are focused. True when the control and one of its editors are focused. Maximum length for the value in the composite editor control.

The property value contains the maximum length from the TCustomEdit control in ActiveControl. Changing the value for the property causes the MaxLength property in the TCustomEdit control to be updated.

Contains the active editor control for the composite cell editor.

ActiveControl is a read-only TWinControl property which contains the active editor control for the composite cell editor. The property value is retrieved from the internal list of TEditorItem instances added to the composite editor using the AddEditor method.

Each of the TEditorItem instances is visited until an editor with its ActiveControl property set to True is found. The return value contains the control found in the internal list, or Nil if none of the editor controls are the active editor in the composite cell editor.

ActiveControl is used in the implementations for properties and methods in the class, like:

  • Focused
  • MaxLenth
  • SetColor
  • SetFocus
  • SendChar
  • AddEditor
Defines the event handler signalled to draw a cell on a grid control.

TOnDrawCell is the type used to implement the OnDrawCell event handler in TCustomGrid.

Grid control for the event notification. Column number to draw in the event handler. Row number to draw in the event handler. Rectangle to draw in the event handler. Grid drawing state used in the event handler. Specifies the event handler signalled when a cell is selected in a grid control.

TOnSelectCellEvent specifies the event handler signalled when a cell is selected in a custom-drawn grid control. TOnSelectCellEvent is the type used to implement the OnSelectCell in TCustomDrawGrid.

Control for the event notification. Column number for the selection notification. Row number for the selection notification. Set to True if the specified cell can be selected. Specifies an event handler signalled for a selection in a grid control.

TOnSelectEvent specifies an event handler signalled when a selection is made in a grid control. TOnSelectEvent is the type used to implement event handler properties in TCustomGrid, including:

  • OnAfterSelection
  • OnBeforeSelection
  • OnButtonClick
  • OnSelection

Applications must implement an object procedure using the signature for the event handler to respond to the event notification.

Control generating the event notification. Column number for the selection. Row number for the selection. Defines the event handler signalled when rows or columns are added, deleted or moved in a grid.

TGridOperationEvent specifies an event handler signalled when rows or columns are added, deleted or moved in a custom-drawn grid control. TGridOperationEvent is the type used to implement event handler properties in TCustomDrawGrid, including:

  • OnColRowDeleted
  • OnColRowExchanged
  • OnColRowInserted/
  • OnColRowMoved

Applications must implement an object procedure using the signature for the event handler to respond to the event notification.

Control for the event notification. True when the notification is for a column and not a row. Starting index position for the row or column. Final index position for the row or column. Specifies an event handler signalled when an event occurs in a fixed header cell.

THdrEvent specifies an event handler signalled when an event occurs in a column header. Arguments passed to the event handler indicate whether the action occurred for a column or a row header, and the index position for the row or column.

THdrEvent is the type used to implement the OnHeaderClick and OnHeaderSized properties in TCustomDrawGrid. Applications must implement an object procedure using the event signature to respond to the event notification.

Control generating the event notification. True if the event applies to a column header; False when a row header is affected. Index position for the row or column in the event notification. Specifies an event handler signalled to compare cell values.

TOnCompareCells specifies an event handler signalled to compare the cells at the coordinates in ACol, ARow, BCol, and BRow. ACol and ARow are the column and row numbers for the first value in the comparison. BCol and BRow are the column and row number for the second value in the comparison.

Result is a variable Integer argument used to return the relative sort order for the compared values. The event handler must perform the actions needed to compare the cell values, and set the value in Result accordingly. Result should contain the following values:

-1
The cell value at ACol, ARow occurs before the value at BCol, BRow
0
The compared cells contain the same values
1
The cell value at ACol, ARow occurs after the cell value at BCol, BRow

TOnCompareCells is the type used to implement the OnCompareCells in TCustomGrid.

Relative sort order for the compared values. Control generating the event notification. Column number for the first compared cell value. Row number for the first compared cell value. Column number for the second compared cell value. Row number for the second compared cell value. Specifies an event handler signalled to get an editor control for the specified cell.

TSelectEditorEvent specifies an event handler signalled to get an editor control for the cell at the coordinates in ACol and ARow.

Editor is the TWinControl or descendent class instance to use as the cell editor for the given cell.

TSelectEditorEvent is the type used to implement the OnSelectEditor in TCustomGrid. Applications must implement an object procedure using the event signature to respond to the event notification.

Control generating the event notification. Column number for the cell editor. Row number for the cell editor. Editor control to use for the specified cell. Specifies an event handler signalled when preparing the canvas for a grid control.

TOnPrepareCanvasEvent specifies an event handler signalled when the canvas for a grid control is prepared for rendering. TOnPrepareCanvasEvent allows the canvas for the grid control to be configured prior to rendering cell data.

Sender is the grid control triggering the event notification.

ACol and ARow are the column and row numbers (respectively) for the grid cell in the event notification.

AState contains the grid drawing state for the cell data.

TOnPrepareCanvasEvent is the type used to implement the OnPrepareCanvas in TCustomGrid. Applications must implement an object procedure using the event signature to respond to the event notification.

Grid control for the event notification. Column number for the cell in the event notification. Row number for the cell in the event notification. Grid drawing state for the cell in the event notification. Specifies an event handler signalled to get the user-supplied bitmap for a check box cell.

TUserCheckBoxBitmapEvent is the type used for the OnUserCheckboxBitmap property in TCustomGrid.

Object (TCustomGrid) for the event notification. Column number for the cell with the check box. Row number for the cell with the check box. Checked state for the check box. Bitmap image with the state needed for the check box cell. Specifies the event handler used to get the image drawn for a check box column.

TUserCheckBoxImageEvent specifies an event handler signalled to get the image drawn for a grid cell which displays a Checkbox.

Sender is the grid control generating the event notification.

ACol and ARow are the column and row numbers (respectively) for the cell where the check box is drawn.

CheckedState indicates whether the check box is drawn using the Checked state.

ImageList contains the images used for the Unchecked and Checked states.

ImageIndex indicates the image in ImageList used for the drawing operation.

TUserCheckBoxImageEvent is the type used to implement the OnUserCheckboxImage in TCustomGrid. Applications must implement an object procedure using the event signature to respond to the event notification.

Grid generating the event notification. Column number for the cell. Row number for the cell. State for the check box. Image list with unchecked and checked images. Position of the image in ImageList to use for the check box cell. Specifies the event handler used to validate the content in a grid cell.

TValidateEntryEvent specifies an event handler used to validate the content in a grid cell. TValidateEntryEvent is the type used to implement the OnValidateEntry in TCustomGrid. Applications must implement an object procedure using the event signature to respond to the event notification.

Grid generating the event notification. Column number for the cell. Row number for the cell. Value checked in the event handler. Value returned from the event handler. Specifies an event handler signalled when the value in a check box cell is changed.

TToggledCheckboxEvent specifies an event handler signalled when the value in CheckBox-style cell is changed in a grid. Arguments passed to the event handler identify the grid control for the event notification, the row and column numbers for the altered cell, and the state for a check box cell editor.

TToggledCheckboxEvent is the type used to implement the OnCheckboxToggled in TCustomGrid and descendent classes. Applications must implement an object procedure using the signature for the event handler to respond to the event notification.

Grid control for the event notification. Column number for the altered cell. Row number for the altered cell. State for the check box in the associated cell editor. Specifies an event handler signalled when a fixed cell header in a grid is resized.

THeaderSizingEvent specifies an event handler signalled when a fixed cell header in a grid is resized. Arguments passed to the event handler identify the grid control for the event, and information the row or column affected by the operation.

THeaderSizingEvent is the type used to implement the OnHeaderSizing property in TCustomDrawGrid. Applications must implement an object procedure using the signature for the event to allow responding to the event notification.

Grid control for the event notification. True when the affected cell is a column header; False when it is a row header. Position of the row or column in the grid control. Size (in pixels) for the resized cell. Specifies an event handler used to process the value in a grid cell.

TCellProcessEvent specifies an event handler used to process the value in a grid cell in TCustomStringGrid. Arguments to the event handler identify the grid generating the event notification, the row and column numbers for the affected cell, and the value for the cell after processing. The processType argument specifies whether aValue is copied from or pasted to the cell.

TCellProcessEvent is the type used to implement the OnCellProcess in TCustomStringGrid. Applications must implement an object procedure using the signature for the event handler to respond to the event notification.

Grid control generating the event notification. Column number for the cell in the event notification. Row number for the cell in the event notification. Process to perform on the cell value. Value for the cell after processing has been applied. Event used to get cell hints.

TGetCellHintEvent is an object procedure type used to get a hint for a string grid cell. TGetCellHintEvent is the type used for the OnGetCellHint property in TCustomGrid.

Arguments passed to the procedure can be used to determine the content in HintText displayed as the cell hint.

The grid for the notification. Column index for the notification. Row index for the notification. Text displayed as hint for the cell. Specifies an event handler used to load/save the configuration for a grid column.

TSaveColumnEvent is the type used to implement the OnLoadColumn and OnSaveColumn properties in TCustomGrid.

Grid for the event notification. Column object for the event notification. Index of the column in the grid. XML configuration file for the column information. Grid version for the event. Path expression in the configuration file the column. Implements a grid with metadata where rows and columns are stored as Pointer arrays.

TVirtualGrid is a class used to represent a grid where the rows and columns containing grid metadata are stored as arrays of Pointers. Data stored in the grid includes the Size for data in a cell, and pointers to attributes for fixed and normal cell display.

TVirtualGrid is the type used for an internal member in TCustomDrawGrid.

Gets the value for the indexed Celda property. Value for the property. Column number for the cell value. Row number for the cell value. Gets the value for the indexed Rows property. Value for the property. Row number for the property value. Gets the value for the indexed Cols property. Value for the property. Column number for the property value. Sets the value for the indexed Celda property. Column number for the cell value. Row number for the cell value. Pointer to the properties for the cell. Sets the value for the indexed Rows property. Row number for the property value. Pointer to the properties for the row. Sets the value for the ColCount property. New value for the property. Sets the value for the RowCount property. New value for the property. Sets the value for the indexed Cols property. Column number for the properties stored in the method. New value for the property. Destroys an Item at the given Row and Column location.

Performs actions needed to free the Item at the specified column and row numbers.

Item is a Pointer to the column/row properties for the cell at the coordinates in Col and Row. No actions are performed in the method when Item is unassigned (contains Nil).

Sender contains the object instance for the column, row, or cell affected in the method. Calls the DisposeColRow method when Sender is for a column or row array. Calls DisposeCell when Sender contains a pointer to another object class.

The value in Item is set to Nil prior to exiting from the method.

doDestroyItem is the default handler assigned to the OnDestroyItem event handler for the cell, column and row arrays used in the virtual grid.

Column, row, or cell properties affected in the method. Column number freed in the method. Row number freed in the method. Pointer to the column, row, or cell properties freed in the method. Creates a new item at the location specified by Col and Row.

This method implements the handler routine assigned to the OnNewItem event handler in the internal class used to maintain row or column values.

TPointerPointerArray.OnNewItem TOnNotifyItem
Class instance where the new item is created. Ordinal column number where the new item is created. Ordinal row number where the new item is created. Pointer to the item data created in the handler routine. Removes a column or a row in the grid. True if a column is affected in the method. False if a row is affected. Ordinal position for the column or row deleted in the method. Moves a column or a row using the specified index positions. True if a column is affected in the method. False if a row is affected. Ordinal position for the column or row relocated in the method. New ordinal position for the specified column or row. Exchanges values for the current column or row with those at the specified position. True if columns are affected in the method. False if rows are affected. Ordinal position for a column or row swapped in the method. Ordinal position for the other column or row swapped in the method. Disposes of the resources and the pointer for the given cell. Pointer to the cell properties freed in the method. Disposes of the specified row or column, and frees its pointer. Pointer to the column or row properties freed in the method. Indicates if the specified ordinal column number is valid for the grid. True if the index is valid for the grid. Ordinal column number examined in the method. Indicates if the specified ordinal row number is valid for the grid. True if the index is valid for the grid. Ordinal row number examined in the method. Constructor for the class instance.

Create is the overridden constructor for the class instance, and calls the inherited method on entry.

Create allocates TPointerPointerArray resources needed for the column, row, and cell arrays used in the class instance. OnDestroyItem and OnNewItem event handlers in the array classes are set to the doDestroyItem and doNewItem methods in the class instance.

Creates sets the default values for the RowCount and ColCount properties to 4 (for both).

TObject.Create
Destructor for the class instance.

Destroy is the overridden destructor for the class instance. Destroy calls Clear to free content in the internal cell, column, and row arrays used in the class instance. Resource allocated to the cell, row, and column arrays are freed. The row and column counts for the virtual grid are reset to 0 (zero).

Destroy calls the inherited destructor prior to exiting from the method.

TObject.Destroy
Clears the content in the virtual grid.

Clear is a method used to remove the content in the virtual grid. Clear ensures that values in the cell, column, and row arrays used in the class instance are cleared. Values in the ColCount and RowCount properties are reset to 0 (zero).

Gets the default values for a new cell added to the grid.

GetDefaultCell is a PCellProps function used to get the default values for a new cell added to the grid. GetDefaultCell calls New to allocate resources for the PCellProps instance in the return value. Nil values are explicitly assigned to the Text and Attr members in the new instance.

GetDefaultCell is called when a value is assigned to a cell in the Celda property and its PCellProps instance has not already been allocated.

Pointer to the cell properties with the default values for a cell. Gets a pointer to the default values used in the column and row properties when added to the instance.

Used in the implementation of the doNewItem method called when a new column or row is added to the virtual grid.

Pointer to the PColRowProps allocated in the method. Number of columns defined for the grid.

ColCount is an Integer property which indicates the number of columns defined for the grid. When a new value for the property is specified, the internal arrays used for column and cell properties are resized to the length in the property value.

Number of rows defined for the grid.

RowCount is an Integer property which contains the number of rows defined for the grid. When setting a new value for the property, the internal arrays used for rows and cells are resized to the length in the new property value.

Provides indexed access to cell properties by their column and row numbers. Celda is an indexed PCellProps property which provides access to the data, attributes, and text for a given cell. Values are accessed by their column and row numbers. Setting a new value for the indexed property causes an existing cell to be freed from the internal cell array (when assigned) by calling DisposeCell. Column number for the cell. Row number for the cell. Provides indexed access to column properties by their ordinal column number. Column number to access in the grid. Provides indexed access to row properties by their ordinal row number. Row number to access in the grid. Inserts either a column or a row at the specified index position. True to insert a column at the given position, False for a row. Position where the column or row is inserted. Provides properties and methods need to represent a column title in a grid.

TGridColumnTitle is TPersistent descendant used to represent properties and methods for the title for a column in a grid. Use the published properties in the class to access the layout and display attributes for the column title, including:

  • Alignment
  • Color
  • Font
  • ImageIndex
  • ImageLayout
  • Layout
  • MultiLine
  • PrefixOption

Use the Caption to read or write the text displayed as the title for a grid column.

Use the Column to read the column reference (assigned in the constructor for the class instance) to which the column title is attached.

TGridColumnTitle is the type used to implement the TGridColumn.Title property.

Updates the column for when font for the title has changed. Class generating the notification. Gets the value for the Alignment property. Value for the property. Gets the value for the Caption property. Value for the property. Gets the value for the Color property. Value for the property. Gets the value for the Font property. Value for the property. Gets the value for the Layout property. Value for the property. Indicates if the Alignment is stored when saving the component.

IsAlignmentStored indicates if the Alignment is used for the component. IsAlignmentStored contains True when the Alignment has been assigned (is not Nil) for the class instance.

It is used in the TCustomGrid.SaveColumns method. It is also used as the storage specifier for the Alignment as used in LCL component streaming.

True if Alignment is available for the column title. Indicates if the Caption is available in the component. True when Caption is available for the column title. Indicates if the Color is assigned for the column title. True when Color has been assigned Indicates if the Font has been assigned for the column title. True when Font has been assigned in the column title. Indicates if the Layout has been assigned in the column title. True when the Layout has been assigned in the column title. Sets the value in the Alignment property. New value for the property. Sets the value in the Color property. New value for the property. Sets the value in the Font property. New value for the property. Sets the value in the Layout property. New value for the property. Indicates if the Font contains a default value.

IsDefaultFont is a read-only Boolean that indicates if the Font contains a default value. The value in IsDefaultFont is set to False when a new value is assigned to the Font property.

Returns the default caption for the column title. Default value for the Caption property. Returns the default alignment for the column title. Default value for the Alignment property. Returns the default color for the column title. Default value for the Color property. Returns the default layout for the column title. Default value for the Layout property. Gets the persistent object which owns the class instance. TPersistent Persistent object which owns the class instance. Specifies the caption used for the column title. New value for the property. Specifies which properties in the persistent object are used during LCL component streaming.

DefineProperties is an overridden method used to define the properties which are included during LCL component streaming. The TFiler instance in Filer is used to set the read and write procedures for specific properties. In TGridColumnTitle, the Caption is written when it has an explicit non-default value. This implements the storage specifier declared for the property.

TFiler instance used to read and write the class during LCL streaming. Constructor for the class instance.

Create is the virtual constructor for the class instance. Create calls the inherited constructor, allocates resources, and sets the default values for members in the class instance.

Create calls the FillTitleDefaultFont method to get the default value used in the Font property. It can contain either the font for titles in the Grid instance or the font for the Column definition; preference is given to the value in the Grid.

Create assigns the FontChanged method as the OnChange event handler for the Font property.

TheColumn contains contains the TGridColumn instance where the column title is used.

TObject.Create
Column class instance where the column title is used. Destructor for the class instance.

Destroy is the overridden destructor for TGridColumnTitle. It frees resource allocated for properties like Font, Alignment, Color, Caption, and Layout. It calls the inherited destructor prior to exiting from the method.

TPersistent.Destroy
Copies property value from the specified persistent object into the current class instance.

Assign is an overridden method used to implement object persistence for the class. When Source is a TGridColumnTitle instance, the values from the following properties are copied:

  • Alignment
  • Layout
  • Caption
  • Color
  • Font
  • ImageIndex

If Source is not derived from TGridColumnTitle, the inherited method is called using Source as an argument.

TPersistent
Persistent object with property values copied in the method. Stores the default font used for the column title.

When Grid has been assigned, the TitleFont property from the Grid is used in the Font property. Otherwise, the Font from the Column is used. IsDefaultFont is set to True in the method.

Corrects the design-time PPI for the column title.

FixDesignFontsPPI is a procedure used to correct the design-time Pixels Per Inch setting for the component. Pixels Per Inch for Fonts is not saved in LFM files, and the design-time setting may differ from the run-time setting on a target machine. This adversely affects font scaling.

FixDesignFontsPPI calls the DoFixDesignFontPPI method in the Grid control for the column to adjust the font PPI to the value specified in ADesignTimePPI.

TControl.DoFixDesignFontPPI
Design-time display density applied in the method. Scales font sizes in the class instance to the specified display density.

ScaleFontsPPI is an overridden procedure used to scale the size for the fonts in the Grid and Title properties to the specified display density (PPI) (Pixels Per Inch).

AToPPI contains the value assigned to the fonts used when a non-zero value is specified.

If AToPPI is omitted, the scaling factor in AProportion is used to adjust the existing PPI setting in the fonts by the indicated factor.

ScaleFontsPPI is called when the AutoAdjustLayout method is used to apply a layout policy to a control.

Explicit Pixels per Inch setting for the fonts. Scaling factor applied to the existing PPI setting for the fonts. Returns True if the column title uses the default property values.

IsDefault is a Boolean function used to determine if the column title uses the default values assigned when the class instance was created. The return value is True when all of the following conditions are met:

  • Alignment is Nil (unassigned).
  • Caption is Nil (unassigned).
  • Color is Nil (unassigned).
  • Layout is Nil (unassigned).
  • ImageIndex is 0 (zero).
  • ImageLayout is blGlyphRight.
  • IsDefaultFont returns True.

IsDefault is when the columns for the parent grid are streamed using the LCL component streaming mechanism. Columns which contain default values (including the title) are not written during component streaming.

True if the column title uses the default property values. The TGridColumn instance where the title is used.

Column is a read-only TGridColumn property with the grid column where the class instance is used as the Title property. Its value is assigned in Create using the argument passed to the constructor.

Column allows access to properties and methods in the grid column owner, including the Grid where the column is defined. It is used in methods like: FontChanged, FillTitleDefaultFont, FixDesignFontsPPI, and ScaleFontsPPI. It is also used when properties are changed which affect the column definition, including: Alignment, Color, Font, ImageIndex, ImageLayout, Layout, MultiLine, and PrefixOption.

Horizontal alignment for the text in the column title.

Alignment is a TAlignment property which controls the horizontal alignment for the text in the Caption property. The default alignment is taLeftJustify, as returned from GetDefaultAlignment, and causes the title to be displayed aligned to the left edge of the column.

Changing the value for the property causes the ColumnChanged method in Column to be called to update the collection item and reset its WidthChanged property.

Use Layout to control the vertical alignment for the text displayed in the column title.

Use ImageLayout to control the position for the glyph image displayed in the fixed header cell for the column title.

TAlignment
Text displayed as the title for the grid column.

Caption is a TCaption property which contains the text displayed as the title for a grid column in a fixed cell header. If an explicit value has not been assigned to Caption, the value from GetDefaultCaption is used as the property value ('Title').

Changing the value for the property causes the ColumnChanged method in Column to be called. This updates the collection item in the Grid where the Column is defined, and resets the value in the WidthChanged property for the Column.

Use Font to control the typeface and display attributes for the text.

Use Alignment to control the horizontal alignment for the text within the cell header.

Use Layout to control the vertical alignment for the text within the cell header.

Use MultiLine to indicate whether the text can be word-wrapped when it is longer than the display width for the column.

Use ImageIndex to specify the glyph displayed for in the cell header for the column.

The background color for the column title.

Color is a TColor property which contains the color used to paint the background for the column header where the title is displayed. If an explicit value has not been assigned, the value from GetDefaultColor is used in the property, and contains the FixedColor for the grid where the Column is defined.

Changing the value for the property causes the ColumnChanged method in Column to be called. This causes the collection item to be updated in the grid control, and the WidthChanged property in Column is reset.

Use the Color property in Font to control the color for the text displayed in the fixed header cell.

TFont.Color
Contains the typeface and text attributes for the Caption displayed in the column title.

Font is a TFont property which contains the name for the typeface and its attributes which are applied to the text displayed in the column title. The default value for the property is assigned in the Create constructor, and uses the value determined by the FillDefaultFont method in the Column. It contains the TitleFont for the grid control (when assigned) or the Column (by default).

Use Alignment to control the horizontal alignment for the text displayed in the column title; this overrides the attributes assigned to Font.

Use Layout to control the vertical alignment for the text displayed in the column title; this overrides the attributes assigned to Font.

TFont
Ordinal position for the image displayed in the fixed header for the column title.

ImageIndex is a TImageIndex property which contains the ordinal position for the image displayed in the column title. It indicates the position in the TitleImageList property on a grid control where the image is stored. The default value for the property is -1 and indicates that an explicit value has not been assigned, or that an image is not used in the fixed header for the column.

Changing the value for the property causes the ColumnChanged method in Column to be called. This updates the collection item in the grid control where the column is defined, and resets the value in the WidthChanged property in Column.

Use ImageLayout to control the position for the image relative to the caption text displayed in the column header.

TImageIndex
The layout used for any image in the column title.

ImageLayout is a TButtonLayout property which controls the placement of the title image relative to the text displayed in the column header. The default value for the property is blGlyphRight, and causes the image to be aligned to the right of the Caption displayed in the column title.

See TButtonLayout for the values allowed in the property and their meanings.

Changing the value for the property causes the ColumnChanged method in Column to be called. This updates the collection item in the grid control where the column is defined, and resets the value in the WidthChanged property in Column.

Use Alignment and Layout to control the placement of the Caption text in the column title.

TButtonLayout
Vertical alignment for the Caption text displayed in the column title.

Layout is a TTextLayout property which indicates the vertical alignment for the caption text within the fixed header for the column. See TTextLayout for the values allowed in the property and their meanings.

If an explicit value has not been assigned to the property, the value from the GetDefaultLayout method (tlCenter) is used as the property value.

Changing the value for the property causes the ColumnChanged method in Column to be called. This updates the collection item in the grid control where the column is defined, and resets the value in the WidthChanged property in Column.

Use Alignment to control the horizontal alignment for the Caption text displayed in the column title.

Use MultiLine to control text wrapping when Caption is longer than the display width for the Column.

Use ImageLayout to control the placement of an image relative to the Caption in the column title.

TTextLayout
Indicates whether the column title can be displayed as multiple lines.

MultiLine is a Boolean that indicates if the column title can be displayed as multiple lines. The default value for the property is False. Changing the value in MultiLine cause the ColumnChanged method for the TGridColumn class instance to be called.

Indicates if accelerator keys are used in the column title.

PrefixOption is a TPrefixOption that indicates if accelerator keys are recognized and displayed in the column title. The default value for the property is poNone, and indicates Accelerator keys are ignored for the column title. Changing the value in PrefixOption causes the ColumnChanged method for the TGridColumn class instance to be called.

Implements a column definition used for tabular data in TCustomGrid.

TGridColumn is a TCollectionItem descendant which implements a column definition for grid controls. TGridColumn contains properties which control the appearance, layout, and editing behavior used for a column in TCustomGrid and descendent classes. For instance:

  • Alignment
  • ButtonStyle
  • Color
  • DropDownRows
  • Font
  • Layout
  • MinSize
  • MaxSize
  • PickList
  • ReadOnly
  • Width
  • Visible
  • ValueChecked
  • ValueUnchecked

The column has an associated TGridColumnTitle class instance in Title that defines the fixed cell header displayed for the column. As a convenience, the column includes a reference to the TCustomGrid which uses the column definition.

Instances of TGridColumn are created by and stored in the TGridColumns collection class. Use the methods in TGridColumns to create, access, and maintain the items in the collection.

Performs actions needed when the Font has been changed for the grid column.

FontChanged is a procedure used to perform actions needed when the Font for the grid column has been changed. For TGridColumn, it sets the value in IsDefaultFont to False and calls the ColumnChanged method.

Class instance generating the notification. Gets the value for the Alignment property. Value for the property. Gets the value for the Color property. Value for the property. Gets the value for the Expanded property.

Always returns True in the current implementation.

Value for the property. Gets the value for the Font property. Value for the property. Gets the value for the Grid property. Value for the property. Gets the value for the Layout property. Value for the property. Gets the value for the MaxSize property. Value for the property. Gets the value for the MinSize property. Value for the property. Gets the value for the SizePriority property. Value for the property. Gets the list of strings in the picklist. Value for the property. Gets the value for the ReadOnly property. Value for the property. Gets the value for the Visible property. Value for the property. Gets the value for the Width property. Value for the property. Indicates if the Alignment is used for the class instance. True when Alignment has been assigned in the class instance. Indicates if the Color is used in the class instance. True when Color has been assigned in the class instance. Indicates if the Font has been assigned for the column. True when Font has a value other than the default font. Implements the storage specifier for the ImageLayout property. True when the property member contains a value other than Nil. Implements the storage specifier for the MinSize property. True when the property member contains a value other than Nil. Implements the storage specifier for the MaxSize property. True when the property member contains a value other than Nil. Implements the storage specifier for the ReadOnly property. True when the property member contains a value other than Nil. Implements the storage specifier for the SizePriority property. True when the property member contains a value other than Nil. Implements the storage specifier for the Visible property. True when the property member contains True. Implements the storage specifier for the Width property. True when the property member contains a value other than Nil. Sets the value in the Alignment property. New value for the property. Sets the value in the ButtonStyle property. New value for the property. Sets the value in the Color property. New value for the property. Sets the value in the Expanded property. New value for the property. Sets the value in the Font property. New value for the property. Sets the value in the Layout property. New value for the property. Sets the value in the MaxSize property. New value for the property. Sets the value for the MinSize property. New value for the property. Sets the value for the PickList property. New value for the property. Sets the value for the ReadOnly property. New value for the property. Sets the value for the SizePriority property. New value for the property. Sets the value for the Title property. New value for the property. Sets the value for the Visible property. New value for the property. Sets the value for the Width property. New value for the property. Copies property values from the specified persistent object to the current class instance.

Assign is an overridden method in TGridColumn. It implements the object persistence mechanism from the FPC RTL. Assign copies property value from the persistent object in Source into the current class instance.

When Source is derived from TGridColumn, the following properties are copied in the method:

  • Alignment
  • ButtonStyle
  • Color
  • DropDownRows
  • Font
  • Layout
  • MinSize
  • MaxSize
  • PickList
  • ReadOnly
  • SizePriority
  • Title
  • Width
  • Visible

If Source is not derived from TGridColumn, the inherited Assign method is called.

TPersistent.Assign
Persistent object with properties copied in the method. Gets the default value for the Alignment property.

GetDefaultAlignment is a TAlignment function used to get the default value for the Alignment property in the grid column.

GetDefaultAlignment uses the value in ButtonStyle to determine the alignment needed for the grid column instance. When ButtonStyle contains cbsCheckboxColumn or cbsButtonColumn, the alignment is set to taCenter. Otherwise, the alignment is set to taLeftJustify.

GetDefaultAlignment is called when reading the value for the Alignment property, and the value in the property member has not been assigned (contains Nil). It is also called when setting a new value in Alignment, and determines whether the property member needs to be re-allocated for the modified value.

TAlignment instance with the default alignment for the grid column. Gets the default value for the Color property.

GetDefaultColor is a TColor function used to get the default value for the Color property in the grid column. The return value is set to the Color property in Grid, when it has been assigned. When Grid contains Nil, the value clWindow is used as the return value.

GetDefaultColor is called when reading the value for the Color property, and the property has not been assigned. It is also called when setting a new value in Color, and determines whether the property member is re-allocated for the new value.

Default value for the Color property in the grid column. Default layout used for text in the grid column.

GetDefaultLayout is a TTextLayout function used to get the default value for the Layout property in the grid column. The return value is always tlCenter in TGridColumn.

GetDefaultLayout is called when reading the value for the Layout property, and an explicit value has not been assigned for the property. It is also called when setting a new value in Layout, and determines whether the property member is re-allocated for the new value.

Default value for the Layout property. Gets the default value for the MaxSize property.

The return value is always 200 (pixels) in TGridColumn.

GetDefaultMaxSize is called when reading or writing the value for the MaxSize property if an explicit value has not already been assigned for the member.

Default value for the MaxSize property. Gets the default value for the MinSize property. Default value for the MinSize property. Gets the default value for the ReadOnly property. Default value for the ReadOnly property. Gets the default value for the SizePriority property. Default value for the SizePriority property. Gets the default value for the Visible property. Default value for the Visible property. Gets the default value for a checked cell in the grid column. Default value for a checked cell in the grid column. Gets the default value for an unchecked cell in the column. Default value used for an unchecked cell in the grid column. Gets the default value for the Width property. Default value for the Width property. Performs actions needed when a column in the grid is changed.

Calls Changed to update the current column instance in the Columns collection. The internal flag used to track changes to the column width is reset after updating the collection item.

Method used to indicate that all columns in the collection have been changed. Creates a column title used for the grid column. TGridColumnTitle instance created in the method. Sets the value for the Index property.

SetIndex is an overridden method in TGridColumn used to set the value for the inherited Index property. When the property value is changed, and Grid is assigned, columns in the grid control are re-ordered to reflect their new value for the column (when needed). The inherited method is called to apply the new property value prior to exiting from the method.

TCollectionItem.Index
New value for the Index property. Indicates if the default font is in use for the grid column. Constructor for the class instance.

Create is the constructor for TGridColumn. Create calls the inherited Create method using ACollection as the owner for the collection item.

Create allocates resources needed for members in the class instance, and sets the default values for properties such as: Title, Font, IsDefaultFont, ButtonStyle and DropDownRows.

TCollectionItem.Create
Collection which owns the collection item. Destructor for the class instance.

Destroy is the overridden destructor for the class instance. Destroy ensures that resources allocated for members in the class instance are freed (when needed), including:

  • Alignment
  • Color
  • Visible
  • ReadOnly
  • Width
  • Layout
  • MaxSize
  • SizePriority
  • MinSize
  • ValueChecked
  • ValueUnchecked
  • PickList
  • Font
  • Title

Destroy calls the inherited destructor prior to exiting from the method.

TCollectionItem.Destroy
Sets the Font to the value used in the grid control.

When Grid has been assigned, its Font is used in the column instance. The TFont value is assigned to the Font property, and IsDefaultFont is set to True.

FillDefaultFont is called from the FontChanged method in TGridColumns.

Corrects the design-time PPI for the column title.

FixDesignFontsPPI is a procedure used to correct the design-time Pixels Per Inch setting for the component. Pixels Per Inch for Fonts is not saved in LFM files, and the design-time setting may differ from the run-time setting on a target machine. This adversely affects font scaling.

FixDesignFontsPPI calls the DoFixDesignFontPPI method in the Grid control to adjust the font PPI to the value specified in ADesignTimePPI.

TControl.DoFixDesignFontPPI
Design-time display density applied in the method. Scales the fonts for the column to a specified display density using a scaling factor.

ScaleFontsPPI is a method used to scale the height for fonts used to display the data and title in the grid column. It implements the method introduced in TControl, and applies the operation to the fonts used in the TGridColumn instance. It is called from the ScaleFontsPPI method in TCustomGrid when Columns have been defined for the grid control.

ScaleFontsPPI calls the The DoScaleFontPPI method in Grid to adjust the control font using the arguments in AToPPI and AProportion.

AToPPI contains the pixels per inch value assigned to the fonts used when a non-zero value is specified. If AToPPI is omitted (0), the scaling factor in AProportion is used to scale the existing PixelsPerInch setting in the fonts by the factor in AProportion.

The ScaleFontsPPI method in Title is called to adjust the font used in the fixed title displayed for the column. It uses the same logic applied to the control Font.

ScaleFontsPPI is called when the AutoAdjustLayout method is used to apply a layout policy to a control.

TControl.ScaleFontsPPI
Target pixels per inch for the fonts in the grid column. Scaling factor applied to pixels per inch when aToPPI is 0. Indicates if default layout settings are used for the grid column.

IsDefault is a Boolean function used to determine if the grid column uses default values in properties used to layout and configure the class instance. The return value is True when all of the following conditions are met:

  • Alignment is unassigned (Nil).
  • Color is unassigned (Nil).
  • ReadOnly is unassigned (Nil).
  • Width is unassigned (Nil).
  • Layout is unassigned (Nil).
  • MaxSize is unassigned (Nil).
  • MinSize is unassigned (Nil).
  • SizePriority is unassigned (Nil).
  • IsDefaultFont returns True.
  • Title uses default settings.

IsDefault is used during LCL component streaming to determine whether items in the Columns collection need to be included in the resource stream when the private WriteColumns method is called.

True if the column uses its default settings. The grid control to which this column belongs.

Grid is a read-only TCustomGrid property with the grid control where the column instance is stored. Grid allows the column definition to access properties, methods, and events found in the TCustomGrid control where the column is used.

The property value contains the Collection (TGridColumns) for the item, and is passed as an argument to constructor for the class instance. The property value is Nil if the collection is not descended from TGridColumns.

Example uses can be found in methods like SetIndex, GetWidth, GetDefaultWidth, GetDefaultColor, FillDefaultFont and ScaleFontsPPI.

TCollectionItem.Collection
Default width for the column, or -1 when not assigned.

DefaultWidth is a read-only Integer property with the default width used for the column. The property value is read from the DefaultColWidth property in the Grid control (when assigned). If it is not assigned, the property value is -1.

Contains the explicit, non-default value assigned to the Width property.

StoredWidth is a read-only Integer property with an explicit value assigned to the Width property for the column. If an explicit value has not been assigned in Width, the property value is -1.

True when the width for the column has been changed.

Set to True when an explicit value is assigned to the Width property. Its value is set to False when the modified column is stored in the Columns collection in the Grid control.

Indicates the alignment for values displayed in the column: left or right aligned, or centered.

Alignment is a TAlignment property which indicates how data displayed in the column is aligned. If Alignment has not been assigned, the value from GetDefaultAlignment is used in the property. Changing the value for the property causes the ColumnChanged method to be called to update the collection item and reset the value in WidthChanged to False.

Alignment is used when the Grid control prepares its Canvas to draw data cells in the column.

TCollectionItem TAlignment
The style used for a button displayed for cells in the column.

ButtonStyle is a TColumnButtonStyle property which indicates the button style used for cell editors displayed in the column. The default value is cbsAuto, and causes String-based editors with an Ellipsis button to be selected.

See for other values allowed used in the property, and their usage.

Changing the value for the property causes the ColumnChanged method to be called to update the collection item and reset the value in WidthChanged to False.

ButtonStyle is used when the GetDefaultEditor or EditorByStyle methods in Grid are called.

TCollectionItem
Color for the background on the column.

Color is a TColor property with the background color used when values in the grid column are drawn. If an explicit value has not been assigned for the property, the value from GetDefaultColor is used as the property value.

Changing the value for the property causes the ColumnChanged method to be called to update the collection item in its collection.

Use the Font.Color property to set the color for text drawn in the column.

Use Title.Color and Title.Font color properties to set the colors for fixed cells drawn as grid column headers.

TCollectionItem TFont.Color
The number of rows displayed in the drop-down list for a cell editor in the column.

DropDownRows is a Longint property with the number of rows displayed in the drop-down list for the cell editor in the column. The default value is 7.

DropDownRows is assigned to the cell editor retrieved in the GetDefaultEditor method in the Grid control. It is relevant when the ButtonStyle for the column is set or resolved to cbsPicklist in the EditorByStyle method for the Grid control.

TCustomComboBox.DropDownCount
Indicates if the drop-down list in the column cell editor is displayed in an expanded state.

Expanded is a Boolean property which indicates if the drop-down list for the column cell editor is displayed in an expanded state. The default value for the property is True. A value assigned to the property is ignored; write access is not enabled for the property value.

The font used for text displayed in the column.

Font is a TFont property which contains the typeface name and display attributes used to display text for cells in the grid column. By default, Font contains the same value assigned to the Grid control and loaded in the FillDefaultFont method. It is applied to the Canvas for the Grid and used in its DrawCellText method.

Changing the value for the property causes IsDefaultFont to be set to False. The ColumnChanged method is called to update the collection item in the Columns collection for the Grid. The value in WidthChanged is also reset to False.

Use the Font property in Title to set attributes for text displayed in the fixed header cells for the column.

TControl.Font TFont
The layout (vertical alignment) for text displayed in the column.

If Layout has not been assigned, the default value for the property is tlCenter. This causes text for the column to be vertically aligned to the center of the non-fixed cells for the column.

Use the Alignment property to set the horizontal alignment for text displayed in the non-fixed cells for the column.

Use the Layout and Alignment properties in Title to control text displayed in the fixed header for the column.

TTextLayout
The minimum size for the column in pixels.

MinSize and MaxSize are used to determine the smallest and largest sizes for the column when it is resized horizontally. This can occur when the border on the column header is dragged on the Grid control (requires column resizing to be enabled in the Options for the Grid). It can also occur when the AutoFillColumns property in the Grid is enabled and SizePriority is set to a non-zero value.

If MinSize has not been assigned, GetDefaultMinSize is called to get the value for the property. Assigning a new value for the property causes ColumnChanged to be called to notify the column collection when the collection item is updated. WidthChanged is set to False when the collection has been notified of the updated value.

Please note that MinSize and MaxSize are not enforced during manual column resizing (when enabled) if all of its columns have SizePriority set to 0. The last column will still be automatically sized to fill the available space, but the minimum and maximum widths for the column are not applied.

Use Width to set the default size of the column in pixels.

The maximum size for the column in pixels.

MinSize and MaxSize are used to determine the smallest and largest sizes for the column when it is resized horizontally. This can occur when the border on the column header is dragged on the Grid control (requires column resizing to be enabled in the Options for the Grid). It can also occur when the AutoFillColumns property in the Grid is enabled and SizePriority is set to a non-zero value.

If MaxSize has not been assigned, GetDefaultMaxSize is called to get the value for the property. Assigning a new value for the property causes ColumnChanged to be called to notify the column collection when the collection item is updated. WidthChanged is set to False when the collection has been notified of the updated value.

Please note that MinSize and MaxSize are not enforced during manual column resizing (when enabled) if all of its columns have SizePriority set to 0. The last column will still be automatically sized to fill the available space, but the minimum and maximum widths for the column are not applied.

Use Width to set the default size of the column in pixels.

The list with the values that can be selected for a cell in the column using a drop-down list.

PickList is a TStrings property which contains the list of values that can be selected for a cell in the grid column. It is used when the ButtonStyle property is set to cbsPicklist to enable a combo-box-style cell editor for the column. The values in PickList are assigned as the items in the drop-down list for the editor.

Use DropDownRows to control the number of lines displayed in the drop-down list when the cell editor is activated.

Note that the Expanded property always contains True; write access is not enabled for the property.
True if the values in the column cannot be changed at run-time using the cell editor. The auto-sizing priority for the column.

0 indicates that the column is not one of the auto-sized columns in the Grid control. A non-zero value causes the column width to be adjusted when AutoFillColumns is enabled in the Grid control. If all of the columns in a grid control have SizePriority set 0, the last column is resized when AutoFillColumns is enabled.

Use MinWidth and MaxWidth to set the smallest and largest sizes for the column when the column is resized - either manually (by dragging the header border) or when AutoFillColumns is enabled in the Grid control.

Use Width to set the default size for the column in pixels.

Contains a Pointer to an Integer type.

Tag is a PtrInt property which contains a pointer to an numeric integer value. It does not have any predefined usage in TGridColumn.

Contains the attributes for the title in the fixed header for the column.

Title is a TGridColumnTitle property which contains attributes for the fixed header on the column. It includes settings that control the appearance and functionality for the fixed header.

Values in Title can be assigned at design-time using the object inspector, or at run-time in program code.

See TGridColumnTitle for more information about the properties and methods in the class.

The display width in pixels for the column on its Grid control.

Width is an Integer property with the display width for the column in pixels. Its value is used when the column has its Visible property set to True. Otherwise, the property value is 0.

Width can be assigned at design-time using the object inspector in the IDE, or at run-time in program code.

If a value has not been assigned for the property, the DefaultColWidth property from the Grid control is used as the property value.

Width is updated at run-time when the column is resized on the Grid control. This can occur when the border on the fixed header is dragged (when column resizing is enabled in the Options for Grid control). It may also occur when AutoFillColumns is enabled for Grid control.

Use MinSize and MaxSize to specify the smallest and largest widths for the column when SizePriority has a non-zero value.

True if the column is visible (not hidden) on the Grid control. Gets the value for the ValueChecked property.

Returns the value from the GetDefaultValueChecked method if an explicit value has not been assigned for the property.

Value for the ValueChecked property. Gets the value for the ValueUnChecked property.

Returns the value from the GetDefaultValueUnchecked method if an explicit value has not been assigned for the property.

Value for the ValueUnchecked property. Contains the checked value for a check box in the column. Contains the unchecked value for a check box in the column. Stores data about rows and columns used in a TCustomGrid class instance.

TGridPropertyBackup is a record type used to store data about rows and columns, including fixed cells. Used internally in a TCustomGrid class instance.

Indicates if the grid contains valid row or column counts. Number of fixed rows in the grid. Number of fixed columns in the grid. Number of rows in the grid. Number of columns in the grid. Collection used to store column definitions for a grid control.

TGridColumns is a TCollection descendant that implements a container for column definitions used in TCustomGrid and descendent classes. TGridColumns is the type used to implement the Columns in TCustomGrid.

TGridColumns is used to create, access, and maintain TGridColumn class instances representing the columns in a grid. Use the indexed Items to access a TGridColumn instance in the collection using its ordinal position.

Additional properties and methods are included in the collection that are relevant to their use with grid column definitions. A reference to the TCustomGrid which owns the collection is maintained to provide access to the properties, methods, and events in the grid.

Gets the value for the indexed Items property. Collection the collection item at the specified position. Ordinal position for the requested collection item. Gets the value in the Enabled property. Value for the property. Sets the item at the specified position in the Items property. Ordinal position for the collection item updated in the method. Value stored at the specified position in the collection. Gets the value for the VisibleCount property. Value for the property. Notifies the Grid using the collection when a column is updated. TCollection Collection item requiring the update notification. Performs actions needed when the title font is changed for items in the collection.

TitleFontChanged is a procedure used to perform actions needed when the title font for a grid has been changed. TitleFontChanged examines each of the column definitions in the collection, and updates the default font for the column when it has not been set to another value. TitleFontChanged is called during execution of the OnTitleFontChanged event handler in TCustomGrid.

Performs actions needed when the Font for the grid control is changed.

FontChanged is an overridden method used to perform actions needed when the Font for the grid control has been changed.

FontChanged ensures that the font used for the Canvas is updated to use the value in Font when csCustomPaint is included in the ControlState flags.

Otherwise, the inherited method is called to signal the change in the Font property. The FontChanged method in the Columns collection is also called (when enabled). The new Font is assigned to TitleFont and TitleFontIsDefault is reset to True.

TCustomControl.FontChanged TControl.ControlState TControl.Font
Removes the specified column number from the collection. Ordinal position of the column to remove in the method. Moves the column from the first index to the second. Original position for the column moved in the method. New position for the column moved in the method. Exchanges the positions for the specified columns.

ExchangeColumn is a method used to swap the positions for the grid columns specified in the Index and WithIndex parameters. The arguments contain the ordinal positions for the respective grid columns in Items that are swapped in the method.

ExchangeColumn calls HasIndex to ensure that both values within the range allowed (0..Count-1). An exception is raised if either value is not in the required range for the column collection.

The order for the index positions is not significant; the column with the larger of the two index values is updated first. This prevents an exception from being raised when the column positions are swapped.

ExchangeColumn swaps the values for the Index properties for the corresponding TGridColumn instances in Items. The Grid control associated with the collection is notified when the Index properties are updated, and the grid moves the content for the updated columns.

Raises an Exception if values in Index or WithIndex are not within the range allowed for the collection. TCollectionItem.Index
Position of a column exchanged in the method. Position of the other column exchanged in the method. Inserts a column at the specified index position.

InsertColumn calls the Add method to create a new column instance using the ItemClass for the collection. MoveColumn is called to relocate the newly stored column to the position in the Index argument.

Use the Items property to access the new column by its index position.

TCollection.ItemClass
Position in the collection where the column is inserted. Constructor for the class instance.

Create is the constructor for the class instance, and calls the inherited method on entry using aItemClass as the class type for new items added to the collection. Create stores the value in AGrid to the Grid property.

TCollection.Create
Grid which owns the collection of column definitions. Class reference used to create new items in the collection. Creates a new ItemClass instance with the collection as its owner.

Add is an overridden method used to create a new collection item using the ItemClass class type for the collection. The new class instance has the collection as its owner. Add re-implements the method from the ancestor class.

Use Insert or InsertColumn to create a new collection item and store it at a specified position in the collection.

TCollectionItem TCollection.Add TCollection.Insert TCollection.ItemClass
TGridColumn instance added to the collection. Clears all items in the collection.

Clear calls BeginUpdate to suppress notifications when items are removed from the collection. It also calls EndUpdate when all items have been removed in the method. Clear calls the inherited method to remove the items in the collection.

TCollection.Clear
Gets the grid column in the collection with the specified title.

Calls SameText to perform a case-insensitive comparison between the value in ATitle and the title in each of the columns in the collection.

TGridColumn instance with the specified title, or Nil when not found. Title for the column to retrieved from the collection. The actual grid index for the visible columns in the collection.

RealIndex is an Integer function used to get the ordinal position in the collection for the visible column specified in Index. It is provided to maintain compatibility with older versions of the LCL, where Items was used to access column instances with their visible property set to True. Current LCL version do not have this limitation; they access the collection directly.

The return value is set to the value in the Index argument when it is a value position in the collection. Otherwise, the return value is set to -1.

RealIndex is called from the ColumnIndexFromGridColumn method in TCustomGrid when its Columns collection has been enabled.

Ordinal position in the column for the specified visible column number, or -1 when not a valid position in the collection. Position for the visible column requested in the method. Gets the ordinal position in the collection for the specified column.

IndexOf is an Integer function used to get the ordinal position in the collection for the TGridColumn instance specified in Column. The return value contains the ordinal position (in the range 0 to Count-1), or -1 when no items exist in the collection or when Column cannot be located in the container.

TCollection.Count
Ordinal position for the collection item, or -1 when not found. Grid column to locate in the collection. True if the columns contain default values only. True if the columns use default settings in their column settings and titles, and contain no explicit property assignments. True if the specified index value is valid for the collection.

HasIndex ensures that the value in Index is valid for the collection. The return value is True when Index is in the range 0..Count-1.

TCollection.Count
True when the value is in the range allowed for the collection. Index value examined in the method. The visible index value for the specified column in the collection. Ordinal position for the column within the visible columns for the collection. Ordinal position for the column examined in the method. The Grid which owns the collection and columns.

Grid is a read-only TCustomGrid which provides access to the grid which owns the column collection. The value in Grid is set in the constructor to an argument passed to the method, and used as the value for the Owner property.

Grid can be used to access the properties, methods, and events in the grid class instance. It is used in the implementation of methods in the collection, such as InsertColumn and Update.

TCollection.Owner
Provides indexed access to column definitions in the collection.

Items is an indexed TGridColumn used to access column definitions in the collection by the ordinal position specified in the Index argument. Items is the default for the collection.

Use Add to create and store a new instance of TGridColumn in the collection.

Use InsertColumn to create and store a new collection item at a specific position in the collection.

Use RemoveColumn, Delete or Clear to remove one or all item(s) in the collection.

Use IndexOf to get the ordinal position in the collection for an existing TGridColumn class instance.

TCollection.Delete
Ordinal position for the column definition used as the value. The number of visible columns in the collection. Indicates if the column collection is enabled.

Enabled is a read-only Boolean property which indicates if columns in the collection can be used in the associated Grid control. Enabled is True when VisibleCount contains a value greater than 0 (zero).

Stores mouse coordinates in screen pixels.

TGridCoordinate is an alias for the TPoint type, and used to get mouse coordinates in TCustomGrid and descendent classes. The X and Y members contain pixel screen coordinates for a given cell.

Alias for the TRect type in RTL.

TGridRect is an alias for the TRect type in the FPC Run-time Library (RTL).

TRect
Array type used to store TGridRect instances.

TGridRectArray is an array type used to store TGridRect instances. It is used to track cell selection ranges in a grid control.

Stores size and movement data for columns or rows in a grid.

TSizingRec is a record type used to store size and positioning information for columns or rows in TCustomGrid and descendent classes. TSizingRec is the type used for an internal member in TCustomGrid which is used in methods that perform column or row sizing operations.

Column or row number for the sizing information. Initial offset for the sizing information. Final offset included in the sizing information. Delta change (in pixels) for the column offsets in a resizing operation. True if the row in PrevOffset is updated in a row sizing operation. Offset to a row affected in a row sizing operation. Stores cached information about a grid control.

TGridDataCache is a record type used to store and cache information about a grid control, its layout, and activity. TGridDataCache is the type used to implement the GCache property in TCustomGrid.

Sum of the column widths for fixed cells in a grid. Sum of the row heights for fixed cells in a grid. Sum of the column widths for all cells in a grid. Sum of the row heights for all cells in a grid. Width of the grid control minus the width for the vertical scroll bar. Height of the grid control minus the width of the horizontal scroll bar. The difference between ClientWidth and FixedWidth. The difference between ClientHeight and FixedHeight. Difference between the scroll bar range and the grid page size. Visible non-fixed cell coordinates rectangle. Bottom/Right coordinates in (pixels) for the visible parts of a grid. True when there are no fixed columns to display in a grid. True when there are no fixed rows to display in the grid. True when there are no fixed cells for columns or rows in a grid. Cumulative preceding width per grid column. Cumulative preceding height per grid row. Offset in pixels for the Top/Left column in a grid. Offset in pixels for the Top/Left row in a grid. Cell coordinates for the last cell that can be used as the grid visual origin. Max Top left offset for the last cell in the grid. The current "hot" cell in the grid. True if the current "hot" cell has already been painted. GridZone for the last MouseMove. Cell coordinates for the last mouse click event. Mouse coordinates for the last mouse click event. Cell coordinates for the cell drawn in the pushed state. Mouse Coordinates for the cell drawn in the pushed state. Indicates if the header cell is currently drawn in the pushed state. Visible cells excluding partially visible cells. Cell which contains the mouse pointer. Previous MaxTopleft (before column sizing). Enumerated type with cursor states available in a grid.

TGridCursorState is the type used for the CursorState property in TCustomGrid.

Normal cursor shape/style. Cursor displayed when changing the width for a column. Cursor displayed when resizing the height for a row. Cursor displayed when dragging a row or column. Specifies an event handler routine used to scroll a grid control when a column or row is dragged beyond the grid client area.

Dir is a TPoint instance which indicates the scroll direction for a grid control. The X and Y members in Dir can contain position or negative values. A negative value indicates the scroll direction is to the left (X) or top (Y) of the grid control. A positive value indicates the scroll direction is to the right (X) or bottom (Y). The values cause the top and/or left visible column on the grid to be adjusted by the indicated amount.

TGridScrollerDoScroll is the type used to implement the internal callback routine in the TGridScroller class. It uses the private ScrollerDoScroll method in TCustomGrid as the handler routine called when a mouse movement is handled in the control.

TPoint instance with delta values indicating the scroll direction. Scrolls an associated grid when a column or row is dragged beyond the client area for the control.

TGridScroller provides methods and internal members which implement a timer-based callback routine fired every 200ms (milliseconds). The routine handles scrolling a grid control in a given direction by changing the top/left visible cell for the control. The callback routine is passed as an argument to the constructor for the class instance, and points to a private method in the TCustomGrid instance.

TGridScroller is used in the implementation of TCustomGrid. The callback routine is signalled when MouseMove handles a row or column drag operation for the control. The class instance is created as needed, and freed when the drag operation is completed in the MouseUp method for the grid control.

Constructor for the class instance.

Create sets the internal Callback member to the handler routine in the DoScroll argument. It also creates the internal TTimer instance used in the class; the timer Interval internal is set to 200ms (milliseconds) and the OnTimer routine is set to the private TimerTick method in the class.

TTimer.Interval TTimer.OnTimer
Contains the callback routine signalled when the timer has elapsed in the class instance. Destructor for the class instance.

Destroy is the overridden destructor for the class instance. It frees resources allocates for the TTimer instance in the class. Destroy calls the inherited destructor prior to exiting from the method.

TTimer
Stores the scroll direction and starts the internal timer for the class instance.

Start is a method used to configure and activate the scroller class instance.

Start stores the value from the ADir argument to the Dir member in the class instance. The TPoint value contains the relative scroll direction for the associated grid control. The X member indicates the horizontal scroll direction; -1 scrolls toward the left, and 1 scrolls toward the right. Similarly, the Y member indicates the vertical scroll direction; -1 scrolls toward the top, and 1 scrolls toward the bottom.

Start sets the value for the Enabled property in the internal TTimer instance to True. This causes the Callback routine, passed as argument to the constructor, to be executed when the time Interval (200ms) has elapsed.

Start is called when a TGridScroller instance is assigned for the grid control, and occurs when column or row drag operations are handled for the control.

TPoint
TPoint instance with the relative scroll direction for an associated grid control. Implements the base class for grid controls.

A grid is a collection of cells that are organized in columns and rows. Grids are suitable for showing data that using a tabular layout. For example: tables in a database, or formulae and data in a spreadsheet.

Key properties:

The ColCount and RowCount properties contain the column and row count of the grid.

The FixedCols and FixedRows properties specify the count of fixed columns or rows that are used for headings.

The column widths and row heights of the grid are accessible with the ColWidths and RowHeights properties.

The DefaultColWidth and DefaultRowHeight properties are used to specify default column widths or row heights respectively.

The colors used for the cells and other grid elements are specified in the following properties:

  • AlternateColor
  • BorderColor
  • FixedColor
  • FixedHotColor
  • FocusColor
  • GridLineColor

The GridWidth and GridHeight properties contain the dimension of the entire grid.

The ScrollBars controls the creation of scroll bars for the grid.

The LeftCol, TopRow, VisibleColCount and VisibleRowCount properties contain information about the visible area of the grid.

The Options controls options for the grid.

Please note that most of these properties are declared as protected members. They are not accessible, by default, at design-time using the Object Inspector in the Lazarus IDE. They can, however, be elevated to public or published visibility in descendent classes.

Key methods and events:

If the user highlights a cell of the grid, the SelectCell method is called that triggers the OnSelectCell event. The position of the highlighted cell is stored within the Col and Row property.

The MouseToCell method calculates a grid cell from a given screen position.

Huge changes to the grid should be encapsulated in calls to BeginUpdate and EndUpdate to speed up the application.

Component developers must override the DrawCell method in customized grid controls.

Additional information about grid usage is available on the Lazarus wiki in the following pages:

  • Grids Reference Page
  • TDrawGrid
  • TStringGrid
Adjusts a row or column count.

AdjustCount is a procedure used to adjust the row or column count for the grid, and to update properties and cache information for the grid.

IsColumn indicates if the OldValue and NewValue arguments refer to the column or row count for the grid; when IsColumn is True, the values refer to the column count.

OldValue contains the previous row or column count in the grid.

NewValue contains the row or column count on exit from the method.

AdjustCount is called when the value in the RowCount or ColCount is changed. It calls the UpdateCachedSizes and SizeChanged methods. It may also call FixPos when NewValue causes the row or column to be out of range for the grid control.

True when the count values are for a columns instead of rows. Count value before adjustment. Count value after adjustment. Caches information about visible parts of the grid (excluding fixed cells). Removes the active range selection for the grid.

Ensures that a selection range is re-created for the current cell, or the current row when goRowSelect is included in the Options for the grid. The value in SelectActive is set to False.

Ensures that the specified column and row counts for fixed cells are valid.

CheckFixedCount is called when new values are assigned to the ColCount, RowCount, FixedCols, or FixedRows properties. It raises an EGridException exception if argument value are not valid or not in range for the grid control.

See CheckCount for the actions performed to validate column and row count values.

Raises an EGridException if values in AFCol or AFRow contain negative values, or are not in range for the values specified in ACol or ARow.
Number of columns for the grid control. Number of rows mined in the method Number of fixed columns for the grid control. Number of fixed rows for the grid control. Ensures that values in Col and Row are range limited to the corresponding arguments values.

CheckCount is a method used to ensure that values in the Col and Row property are valid for the arguments specified in the ANewColCount and ANewRowCount arguments. If the existing Col or Row values would exceed the new values, they are adjusted to fall within the new range (0..n-1).

If either Col or Row is modified in the method, the visible top/left cell for the control is moved (when needed). FixEditor indicates whether the cell editor should be repositioned by calling MoveNextSelectable when the value in Col or Row has been changed. The default value for the argument is True.

No actions are performed in the method if the Handle has not been allocated for the widgetset class instance.

CheckCount is called when new values are assigned to the ColCount or RowCount properties, and when a delete operation is performed for a column or row in the grid. It occurs after the CheckFixedCount method has been called to validate new fixed column or row count values.

New column count for the control. New row count for the control. Ensures a row or column index is not out of range.

CheckIndex is a procedure used to ensure that an index value is within the range of values allowed for a row or column.

IsColumn indicates whether a row or column index is being checked. When set to True, a column index is verified. When set to False, a row index is examined.

IsColumnIndexValid or IsRowIndexValid is called to validate the value in Index. An EGridException exception is raised when Index in not allowed for the corresponding dimension.

CheckIndex is called from methods like Sort, DoOPMoveColRow, and DoOPDeleteColRow.

Raises an EGridException exception with the message in rsGridIndexOutOfRange when Index is not valid for the row or column.
True when the Index is for a column; False when it is for a Row. Column index examined in the method. Determines if the TopLeft cell needs to be changed in the grid cache.

The return value is True if the cached value in TopLeft needs to be updated to reflect the origin cell for the grid control.

Calls TopLeftChanged (when needed) and VisualChange to cause the control to be redrawn.

True if the top left cell was different than the cached value for the grid. Gets the value for the ColRow property. Value for the property. Sets the value for the ColRow property. New value for the property. Indicates if the specified cell is a non-fixed cell which contains a button for each row in the column.

IsCellButtonColumn calls ColumnFromGridColumn to get the TGridColumn which represents the column number in ACell. The return value is True when the following conditions are met:

  • Columns has been enabled for the grid control.
  • The column number in ACell (X) is valid in the grid Columns.
  • The row number in ACell (Y) is not within the FixedRows for the grid.
  • The column definition (TGridColumn) uses cbsButtonColumn in its ButtonStyle property.

IsCellButtonColumn is used in the implementations for the PrepareCanvas, DefaultDrawCell, and IsMouseOverCellButton methods.

True when the column exists and displays a button in its cells. TPoint instance with the column and row numbers for the cell. Gets the value for the SelectedColumn property. Value for the SelectedColumn property. Sets the value for the AlternateColor property. New value for the AlternateColor property. Sets the value for the AutoFillColumns property. New value for the AutoFillColumns property. Sets the value for the BorderColor property. New value for the BorderColor property. Sets the value for the ColumnClickSorts property. New value for the ColumnClickSorts property. Sets the value for the Columns property. New value for the Columns property. Sets the value for the EditorOptions property. New value for the EditorOptions property. Sets the value for the EditorBorderStyle property. New value for the EditorBorderStyle property. Sets the value for the AltColorStartNormal property. New value for the AltColorStartNormal property. Sets the value for the Flat property. New value for the Flat property. Sets the value for the FocusRectVisible property. New value for the FocusRectVisible property. Sets the value for the TitleImageList property. New value for the TitleImageList property. Sets the value for the TitleImageListWidth property. New value for the TitleImageListWidth property. Sets the value for the TitleFont property. New value for the TitleFont property. Sets the value for the TitleStyle property. New value for the TitleStyle property. Sets the value for the UseXorFeatures property. New value for the UseXorFeatures property. Performs actions needed when a column in the grid is resized.

doColSizing is a Boolean function used to perform actions needed when a column in the grid is resized. X and Y contain the mouse coordinates where the action was initiated. The return value contains True when the resizing operation is successfully completed.

No actions are performed in doColSizing if the GridState member contains any value other than gsColSizing. The GridFlags member is updated to include the value gfSizingStarted, and the ResizeColumn and HeaderSizing methods are called to reflect the altered column size.

True when column resizing is successfully completed. Horizontal mouse coordinate where the action was started. Vertical mouse coordinate where the action was started. Performs actions needed when a grid row is resized. Performs actions needed to move or drag a grid column. Performs actions needed to move or drag a grid row. Performs actions needed to render a cell using its "Pushed" appearance. Performs actions needed when the origin or dimensions for the grid are changed. True when the dimensions for the grid have been altered. Draws a vertical line at the specified horizontal location using XOR pen mode. Horizontal location where the vertical grid line is drawn. Draws a horizontal line at the specified vertical location using XOR pen mode. Vertical location where the horizontal grid line is drawn. Gets the value for a cell editor.

EditorGetValue is a Boolean function used to get the value for a cell editor in the grid. EditorGetValue is used in the implementation of TCustomGrid methods like: EditorShowInCell, ResetEditor, MoveExtend, and DestroyHandle. It is used to get the cell value prior to editing, and to display the value from the cell editor when it is hidden.

Validate is a Boolean argument that indicates if the ValidateEntry method is called to validate the edited cell value. When it contains True, ValidateEntry is called prior to calling EditorDoSetValue and/or EditorHide.

The return value contains True when the edited cell value is valid. It also contains True if a cell editor has not been assigned or is not visible, or the method was called at design-time or during component destruction.

True when the cell is valid or has not been altered. Indicates the cell value is validated using ValidateEntry. Sets the position and size for an active cell editor in the grid.

EditorPos is a procedure used to set the position and size for an active cell editor in the grid. EditorPos posts messages to the Editor for the grid, and requires a valid handle for both the grid control and the editor control. No actions are performed in the method when a Handle has not been allocated for the grid or when Editor is unassigned (contains Nil).

A TGridMessage instance with the values in Grid, Col, and Row is dispatched to the Editor to set the Editor position. The bounds for the editor rectangle is calculated and adjusted when needed.

The Font for the grid control is assigned to the Canvas where the editor control is drawn.

A TGridMessage instance with the values in Grid, Col, Row, and the calculated bounds is dispatched to the Editor to set the Editor bounds.

EditorPos is called when visual properties are modified in the control and the editor control is visible. For example: SetRowHeight, SetDefRowHeight, AdjustEditorBounds, SetEditorBorderStyle, SetEditorValue, EditorWidthChanged, GridMouseWheel, WMHScroll, and WMVScroll.

TCustomControl.Canvas TControl.Font
Applies a UTF-8-encoded character value to the active cell editor.

Calls SelectEditor to ensure that the cell Editor is active and enabled for the cell at Col and Row. The Editor is displayed (when available) if the value in Ch is handled in the editor control, and is not marked as read-only. The character in Ch is posted to the widgetset class for the grid.

This method bypasses the KeyDown handler for the class instance, and as a result does not automatically reset RowAutoInsert when Ch contains the Backspace key (Ctrl+H). RowAutoInsert is manually set to False in the method when the Backspace character is detected.

UTF-8-encoded character applied in the method. Sets the value for the EditorMode property. New value for the property. Changes the cell editor value and position at run-time.

Calls EditorPos to the set the position for the Editor control used in the active cell. Calls EditorDoSetValue to update the content in the Editor control.

No actions are performed in the method at design-time.

Indicates if a cell editor is always displayed for an active non-fixed cell in the grid control.

The return value is True when editing is allowed for the cell, it is not a fixed cell, and goAlwaysShowEditor is included in the Options property.

True when a cell editor is allowed and enabled in grid cells. Ensures that column and row positions, and selection(s) are valid for the grid. True if the index value is for a column. False if the value is for a row. Position for the column or row in the grid control. Ensures that scroll bars are updated to reflect the cached visible area in the grid. Gets the value for LeftCol property. Value for the property. Gets the value for the ColCount property. Value for the property. Gets the value for the indexed ColWidths property. Value for the property. Column number to examine in the method. Gets the value for the Columns property. Value for the property. Gets the value for the DefaultColWidth property. Value for the property. Gets the value for the DefaultRowHeight property. Value for the property. Gets the value for the EditorBorderStyle property. Value for the property. Gets the number of pixels needed for the grid border (when used). Number of pixels needed for the grid border. Gets position and layout information for an image used in a column header. Column number examined in the method. Position of the image used for the column. Image layout used for the column. Gets image information displayed in a column header for a sortable grid column.

GetSortTitleImageInfo is used in the implementation of the methods like TCustomGrid.DrawColumnTitleImage and TCustomStringGrid.AutoAdjustColumn.

Column index for the sort indicator. List with images used for the indicator. Image index used for the specified grid column. Image width used for the indicator. Indicates if native sort indicators are defined in the grid column. Gets the value for the RowCount property. Value for the property. Gets the value for the indexed RowHeights property. Height for the row in pixels. Row number for the property value. Gets the value for the indexed SelectedRange property. Value for the property. Ordinal position for the grid selection rectangle. Gets the value for the SelectedRangeCount property. Value for the property. Gets the value for the Selection property. Value for the property. Gets a cursor for the specified grid cursor state.

GetSpecialCursor is used as the read access specifier for the ColRowDraggingCursor, ColRowSizingCursor, and RowSizingCursor properties.

TCursor representing the specified cursor state. Grid cursor state retrieved in the method. Gets the value for the TopRow property. Value for the property. Gets the value for the VisibleRowCount property. Value for the property. Gets a rectangle with the cell coordinates for the visible area in the grid.

Gets a TRect instance with the cell coordinates for the visible area in the grid control.

The visible grid area depends on the values in TopLeft, ClientWidth, ClientHeight, ColCount and RowCount. The method is called immediately after changing values in any of these properties. It provides the current values needed when the grid cache is updated in the CacheVisibleGrid method.

TRect with the cell coordinates for the visible area in the control. Gets the value for the VisibleRowCount property. Value for the property. Performs actions needed to resize columns to fill the client area for the grid control.

InternalAutoFillColumns is a procedure used to resize one or more columns to fill the client area for the grid control. No actions are performed in the method if AutoFillColumns is set to False, or when the method has already been called but has not yet been completed.

InternalAutoFillColumns calls GetAutoFillColumnInfo to accumulate the fixed cell width, data width, and sizing priority for each of the Columns defined in the grid. At least one of the cells in the grid must have sizing priority; the last non-fixed column is expanded to fill the client area in the grid when no other column has sizing priority.

InternalAutoFillColumns is called from the UpdateCachedSizes method.

Indicates if borders are needed to render the grid control. True when a border is drawn around the grid control. Performs internal actions needed to set a column width to the specified value. Column number affected in the method. Width applied to the column. Performs internal actions needed to update columns widths from the grid Columns. Not used in the current implementation. Invalidates the selection rectangle when a range Selection is expanded or shrunk on the grid control. Destination column number with the end of the selection range. Destination row number with the end of the selection range. Range selection rectangle on entry to the method. Indicates if AlternateColor has a value different than the Color for the grid control.

Used as the storage specifier for the AlternateColor property.

True when AlternateColor is different than Color. Indicates if Columns has been enabled for the grid control.

Used as the storage specifier for the Columns property.

True when the Enabled in Columns is True. Indicates if the pushed cell for the grid is visible. Loads column settings from the specified XML configuration file. XML configuration file with values loaded in the method. Version number requested from the XML configuration. Loads a bitmap with the specified name from the resource file for the control. Assumes the resource in ResName can be loaded using TPortableNetworkGraphic, and assigned to the TBitmap return value. TBitmap with the image loaded in the method. Resource name loaded in the method. Loads grid content from the specified XML configuration file. XML configuration file with values loaded in the method. Event handler signalled when the font used for fixed title cells has been changed.

OnTitleFontChanged is a procedure which implements the event handler signalled when the TitleFont for fixed cells has been changed. OnTitleFontChanged is assigned to the OnChange event handler in TitleFont in the constructor for the class instance.

OnTitleFontChanged sets the value in TitleFontIsDefault to False to reflect the change in the font setting. When Columns have been enabled (VisibleCount contains a non-zero value), the TitleFontChanged method in Columns is called. The ColumnsChanged method is called and causes the grid to be updated. If Columns have not been enabled, the VisualChange method is called to update the grid control.

Object generating the event notification. Reads values for the Columns collection using the specified TReader class instance. TReader used to load values during LCL component streaming. Reads the list of Integers in ColWidths using the specified TReader instance. TReader used to load values during LCL component streaming. Reads the list of Integers in RowHeights using the specified TReader instance. TReader used to load values during LCL component streaming. Resets cached grid information for the "pushed" cell.

ResetPushedCell refreshes cached information for the grid related to the current PushedCell. It invalidates the cell at the position in PushedCell when the cached values indicate it is "pushed". Resets coordinates in PushedCell when ResetColRow is set to True. Sets the ClickCellPushed member in the cached data to False prior to exit.

ResetPushedCell is called from methods like HeadersMouseMove and MouseUp. It is also called from the constructor for the TCustomGrid instance.

True (the default value) if PushedCell is reset to an undefined column and row (-1, -1). Restores the internal saved cursor for the grid, and resets CursorState to its default value. Saves column configuration, layout, and appearance to an XML configuration file.

SaveColumns is a method used to store information about columns on the grid to the specified XML configuration file. It stores information about the configuration, layout, and appearance of Columns defined for the grid, including:

  • Columns.Count
  • Columns.Enabled

Information about each of the TGridColumn instances in Columns are written to the XML configuration file, and includes the following:

  • TGridColumn.Index
  • TGridColumn.Width
  • TGridColumn.MinSize
  • TGridColumn.MaxSize
  • TGridColumn.Alignment
  • TGridColumn.Layout
  • TGridColumn.ButtonStyle
  • TGridColumn.Color
  • TGridColumn.ValueChecked
  • TGridColumn.ValueUnChecked
  • TGridColumn.PickList
  • TGridColumn.SizePriority
  • TGridColumn.Font
  • TGridColumn.Title.Caption
  • TGridColumn.Title.Font
  • TGridColumn.Title.Alignment
  • TGridColumn.Title.Color
  • TGridColumn.Title.Layout

SaveColumns calls the DoSaveColumn method for each of the columns to signal the OnSaveColumn event handler (when assigned).

SaveColumns is called from the SaveContent method, and occurs when soDesign has been included in the SaveOptions for the control and the Columns collection has been enabled.

TXMLConfig
XML configuration file where the values are written. Version number for the storage format (tags, attributes) used in the XML configuration file. Scrolls the grid until the cell at the specified location is visible.

Calls TopLeftChanged (when needed) and VisualChange to cause the control to be redrawn.

True if the origin cell (top, left) was changed after scrolling the grid content. Column number for the cell to make visible in the display area for the control. Row number for the cell to make visible in the display area for the control. True to force the entire content for the cell to become visible. False if the cell content can be partially visible. Scrolls the grid until the cell at the specified location is the new origin for the control. Sets the value in the Col property. New value for the property. Sets the value in the indexed ColWidths property. Column number for the update width value. New value for the property. Sets the value for the ColRowDragIndicatorColor property. New value for the property. Sets the value for the DefColWidth property. New value for the property. Sets the value for the DefRowHeight property. New value for the property. Sets the value for the DefaultDrawing property. New value for the property. Sets the value for the Editor property. New value for the property. Sets the value for the FocusColor property. New value for the property. Sets the value for the GridLineColor property. New value for the property. Sets the value for the FixedGridLineColor property. New value for the property. Sets the value for the GridLineStyle property. New value for the property. Sets the value for the GridLineWidth property. New value for the property. Sets the value for the LeftCol property. New value for the property. Sets the value for the Options property. New value for the property. Sets the value for the Options2 property. New value for the property. Sets the value for the RangeSelectMode property. New value for the property. Sets the value for the Row property. New value for the property. Sets the value for the RowCount property. New value for the property. Sets the value in the indexed RowHeights property. Row number affected in the method. New value for the specified row number. Sets the value for the ScrollBars property. New value for the property. Sets the value for the SelectActive property. New value for the property. Sets the value for the Selection property. New value for the property. Sets the value for the indexed cursor states in the grid control.

SetSpecialCursor is used as the write access specifier for the ColRowDraggingCursor, ColRowSizingCursor, and RowSizingCursor properties.

Cursor state located in the method. New value for the cursor state. Sets the value for the TopRow property. New value for the property. Updates the grid to begin a column sizing operation for the specified cell. Changes the cursor shape to the specified value. Cursor shape applied in the method. Indicates if the existing cursor shape is stored for later reuse. Scroll the grid origin by the specified relative columns and rows as needed. Attempts to scroll the grid until the specified coordinates are at the origin for the grid control.

Calls ScrollGrid to scroll the content until the cell at ACol and ARow is the origin (top, left) for the visible area for the control. Calls TopLeftChanged (when needed) and VisualChange to redraw the grid control.

TryScrollTo is called when the value in LeftCol or TopRow is changed. It is also used in the implementation of the GridMouseWheel method.

Column number to become the first visible column on the grid. Row number to become the first visible row on the grid. Performs actions needed when the size for columns or rows are changed. Updates the visibility for horizontal and/or vertical scroll bars. Updates cached information when visual aspects for columns or rows are changed. Writes the Columns collection using the specified TWriter instance.

A Nil collection is written using Writer when Column contains the default column definitions (has not been modified at design-time or run-time).

Not used in the current implementation of TCustomGrid.DefineProperties.
TWriter instance used for the class. Writes the list of Integers in ColWidths using the specified TWriter instance. TWriter instance used to write the values. Writes the list of Integers in RowHeights using the specified TWriter instance. TWriter instance used to write the values. Handles the Window Message used to erase the background for the control. Always returns 1 as the Message result. Lazarus message applied in the method. Handles the Window Message for Tab and Arrow keys in dialogs and custom controls. Examines the Options property for the presence of the goTabs enumeration value. When present, the DLGC_WANTTAB value is OR-ed to the result value in Msg. Lazarus message processed in the method. Member with the current state for the grid (edited, updated, etc.). Gets the positive or negative multiplier used to adjust scroll values for BiDi mode. The return value is 1 for all BiDiMode values except bdRightToLeft; it causes -1 to be returned. Adds the current range selection to the array of selection rectangles for the control.

AddSelectedRange is a method used to add the rectangle for the current range selection to the internal member used to store the selection rectangle(s). It increases the capacity for the member and appends the value for the current selection rectangle.

No actions are performed in the method if goRangeSelect has not been included in the Options property, or when RangeSelectMode has a value other than rsmMulti.

Use ClearSelections to remove range selection rectangle(s) stored using AddSelectedRange.

AddSelectedRange is called from MouseDown when a Ctrl+Click or Meta+Click (macOS) mouse event occurs in the data area for the grid and range selection has been enabled for the control.

Adjusts the client rectangle and sets a grid flag to reflect the change.

AdjustClientRect is an overridden method used to adjust the client rectangle for the control, and set the grid flag to reflect the change. It calls the inherited method on entry. AdjustClientRect updates the GridFlags property to included the value gfClientRectChange.

The method does not perform any real actions other than setting the flag value in GridFlags. gfClientRectChange indicates that the cached sizes for grid Columns needs to be recalculated for the visible area before the grid control is drawn.

TWinControl.AdjustClientRect
Client rectangle adjusted in the method. Updates the selected cell and sets the bounds for the optional cell Editor.

Calls SetColRow to update the values in the Col and Row properties. Values in NewCol and NewRow are stored in the corresponding property.

When EditorMode is set to True, the private EditorPos method is called to position the Editor to the new cell selection.

Column number for the current cell selection in the grid. Row number for the current cell selection in the grid. Signals the OnAfterSelection event handler.

AfterMoveSelection is a procedure used to signal the OnAfterSelection event handler when has been assigned (does not contain Nil). Values in prevCol and prevRow are passed as arguments to the OnAfterSelection event handler.

AfterMoveSelection is called from the MoveExtend method when the move operation has been completed.

Column number for the selection before it was moved. Row number for the selection before it was moved. Stores properties from the current grid class instance to the specified target.

AssignTo is an overridden method used to store values from the current class instance to the persistent object specified in Dest. AssignTo is overridden to provide support for TCustomGrid properties in the object persistence mechanism.

When Dest is a TCustomGrid descendant, the following properties are copied from the current class instance to the target:

Structure

  • Columns (When Columns has been Enabled)
  • ColCount (When Columns has not been Enabled)
  • RowCount
  • FixedCols
  • FixedRows
  • DefaultRowHeight (when it contains a value other than the default)
  • DefaultColWidth (when it contains a value other than the default)
  • The internal Rows list
  • The internal Cols list (when Columns has not been enabled)

Display Settings

  • Options
  • Color
  • FixedColor
  • AlternateColor
  • Font
  • TitleFont

Position and Selection

  • TopRow
  • LeftCol
  • Col
  • Row
  • Current selection range for the grid

When Dest is not a TCustomGrid descendant, the inherited AssignTo method is called using Dest as an argument.

TControl.AssignTo
Grid instance where value are stored. Adjusts column properties to accommodate the largest value in the specified column.

AutoAdjustColumn is called from the DblClick method when the values goColSizing and goDblClickAutoSize have been included in the Options property.

AutoAdjustColumn has an empty implementation in TCustomGrid, and must be overridden in a descendent class like TCustomStringGrid.

AutoAdjustColumn is called from the AutoAdjustColumns method. It also occurs when the mouse is double-clicked on the cell header and column auto-sizing (goColSizing) has been enabled in the Options for the grid control.

Column number adjusted in the method. Performs actions needed before a selection is moved.

BeforeMoveSelection is called from the MoveExtend method whenever the current grid cursor location is about to change. The destination column and row are specified in the DCol and DRow parameters respectively.

The new location is known to be a valid selectable cell (see ), and is given in absolute cell coordinates. At this point the current grid location has not changed and can be retrieved with Col and Row properties.

The purpose of this method is to call the OnBeforeSelection event handler.

Column number where the selection will be stored. Row number where the selection will be stored. Starts an auto-drag operation in the grid control.

BeginAutoDrag is an overridden procedure used to start an auto-dragging operation. Auto-dragging is in effect when DragMode contains the value dmAutomatic.

BeginAutoDrag examines the Options property to determine if column sizing (goColSizing) or row sizing (goRowSizing) have been enabled for the grid control. In addition, the CursorState property must contain a value that represents the action (gcsColWidthChanging or gcsRowHeightChanging). If either condition is not met, BeginDrag is called using False as an argument.

Gets the rectangle for the box around the cell at the given coordinates.

Not used in the current implementation.

Not currently used in the grid implementation.
Updates cached grid information when a mouse click occurs in the grid control. Horizontal screen coordinate for the mouse click. Vertical screen coordinate for the mouse click. Calculates the size for an auto-sized column at the specified position.

CalcAutoSizeColumn sets the value for the aPriority argument to 0 (zero). Other parameters values are not modified.

CalcAutoSizeColumn is not used in the current LCL implementation.
Position for the column definition in Columns. Returns the minimum width for the column. Returns the maximum width for the column. Sizing priority for the column. Higher values are given preference. Deprecated.

This is a remnant from earlier LCL versions. Its has an empty implementation in the current LCL version.

Calculates the bounds for a focus rectangle in the grid control.

When row selection is enabled in the grid Options, the Left and Right values in ARect are updated to use cached grid information in GCache. Calls FlipRect to account for Right-to-Left alignment when needed.

Adjust indicates whether values in ARect are adjusted for horizontal or vertical grid lines drawn in the control. No additional actions are performed when Adjust is set to False. The default value for the parameter is True.

When goHorzLine is included in Options, the Bottom value in ARect is decremented to accommodate the horizontal grid line.

When goVertLine is included in Options, the Left or Right value in ARect is adjusted to accommodate the vertical grid line. Left is incremented when UseRightToLeftAlignment is set to True. Right is decremented when UseRightToLeftAlignment is set to False.

CalcFocusRect is called from the DrawRow and DrawFocusRect methods.

TControl.UseRightToLeftAlignment
TRect instance where the adjusted row or cell selection is stored. Updates cached grid information for the visible area and scroll bars in the control. Updates the range, page, and thumb position for visible scroll bars.

CalcScrollbarsRange is a procedure used to update the range, page, and thumb position for visible scroll bars in the grid control. CalcScrollbarsRange accesses the cached grid data in GCache to calculate values needed in the method. The visibility for both horizontal and vertical scroll bars is determined, and the range, page and thumb position is applied in the UpdateHorzScrollBar and UpdateVertScrollbar methods.

CalcScrollbarsRange is used in the implementation of the ScrollBy and UpdateSizes methods in TCustomGrid.

Gets the preferred width and height for the control.

Always returns 0 (zero) in the PreferredWidth and PreferredHeight variable arguments.

TWinControl.CalculatePreferredSize
Preferred width for a new instance of the class. Preferred height for a new instance of the class. Not used in the current implementation. Indicates whether the cell editor can be displayed and focused in the current column.

CanEditShow is a Boolean function which Indicates whether the cell Editor can be displayed and focused in the current grid column. The return value is False at design-time. The return value is True if Options includes the value goEditing, and the column number in Col is valid and not in a fixed row.

When Columns have been Enabled in the grid control, the return value is set to False when the column is marked as ReadOnly in the column definition.

CanEditShow is called from the EditorShow method.

True at run-time when the column allows focus and editing. Returns True if the grid is able to accept the given key.

Always returns True in TCustomGrid.

True if the grid is able to accept the given key. Not used in the current implementation. Not used in the current implementation. Processes a mouse click in the cell at the given coordinates.

CellClick is a virtual method with an empty implementation in TCustomGrid. It is overridden in descendent classes, like TCustomDrawGrid, to perform action needed in the implementation.

CellClick is called from the MouseUp method when a mouse click event occurs in the data area (non-fixed cells) for the grid control.

Column number for the click event. Row number for the click event. Gets the last column number for the cell extent at the specified column and row.

CellExtent gets the extent rectangle for the cell at the coordinated in ACol and ARow. The rectangle bounds in R are updated by calling the CalcCellExtent method.

exCol is updated in the method to reflect the last visible column in the cached grid information for the cell extent. The ColRowToOffset method is iteratively called until the extent exceeds the cached right-most column for the visible area in the grid.

CellExtent is called from the DrawRow method when column spanning is enabled in the Options for the grid control.

The current implementation does not account for BIDI mode or Right-to-Left usage.
Column number for the cell extent. Row number for the cell extent. TRect with the bounds for the cell extent. Last usable column number for the cell extent. Checks column and row limits for the specified cell.

CheckLimits is a procedure used to constrain the specified cell coordinates to the valid values for grid control.

ACol and ARow contain the column and row numbers for a cell in the grid control. CheckLimits ensures that the values represent a valid, non-fixed cell in the grid control.

ACol must contain a value in the range 0..ColCount-1, and cannot be a fixed column in the grid. The value in FixedCols is assigned to ACol if it is less than the value in FixedCols. ColCount-1 is assigned to ACol when it is larger than the upper limit.

ARow must contain a value in the range 0..RowCount-1, and cannot be a fixed row in the grid. The value in FixedRows is assigned to ARow if it is less than the value in FixedRows. RowCount-1 is assigned to ARow when it is larger than the upper limit.

CheckLimitsWithError is used when an exception is required for invalid cell coordinates.

CheckLimits is used in the implementation of methods like MoveNextSelectable and TryMoveSelection.

Column number examined in the method. Row number examined in the method. Checks column and row limits for the specified cell, with error trapping.

CheckLimitsWithError is a procedure used to ensure that the specified cell coordinates are valid values for grid control.

ACol and ARow contain the column and row numbers for a cell in the grid control. CheckLimitsWithError ensures that the values represent a valid, non-fixed cell in the grid control. ACol must contain a value in the range 0..ColCount-1, and cannot be a fixed column in the grid. ARow must contain a value in the range 0..RowCount-1, and cannot be a fixed row in the grid.

CheckLimitsWithError calls IsColumnIndexValid and IsRowIndexValid to determine whether the corresponding values are valid. If either method returns False, an EGridException is raised.

CheckLimits is used when cell coordinates must be constrained to the values that are valid for the control.

CheckLimitsWithError is used in the implementation of methods like SetCol, SetRow, and SetQuickColRow when AllowOutboundEvents is not enabled.

Raises an EGridException exception with the message in rsGridIndexOutOfRange when a column or row number is out of range for the control.
Column number examined in the method. Row number examined in the method. Handles the CM_BIDIMODECHANGED control message for the grid control.

Calls VisualChange to update column sizes and redraw the control, and calls the inherited method to notify child controls of the new BidiMode value.

Handles the control message posted when the mouse enters a cell in the grid. Message handled in the method. Handles the control message posted when a mouse leaves a cell. Message handled in the method. Performs actions when a column or a row is deleted from the control.

ColRowDeleted has an empty implementation in TCustomGrid. It is overridden in descendent classes to remove the affected cells and perform notifications.

True to remove a column, False to remove a Row. Ordinal position for the column or row removed in the method. Performs a notification when column or row data at the specified positions are exchanged in the grid control.

ColRowExchanged has an empty implementation in TCustomGrid. It is implemented in descendent classes like TCustomDrawGrid to update the content in the grid and signal the OnColRowExchanged event handler (when assigned).

True if columns are affected in the method. False if rows are affected. Position for the initial column or row exchanged in the method. Position for the other column or row exchanged in the method. Performs actions needed when column or row data is inserted into the grid control.

ColRowInserted is a virtual method in TCustomGrid used to perform actions needed when a column or row is inserted into a grid control. The implementation is empty in TCustomGrid, and must be overridden in descendent classes.

The method is called from DoOPInsertColRow and occurs after the Columns definitions for the grid have been updated (when needed and enabled). It occurs before VisualChange is called or the bounds for an editor control are adjusted.

True if the operation inserted a column. False when a row was inserted. Ordinal position for the column or row inserted into the grid control. Performs actions when a column or row is moved in the grid.

ColRowMoved is virtual method in TCustomGrid used to perform actions when a column or a row is moved in the grid control. It has an empty implementation, must be overridden in a descendent class.

ColRowMoved is called from the DoOPMoveColRow method, and occurs after Columns has been updated (when needed and enabled). It occurs before VisualChange is called or the bounds for an editor control are adjusted.

True if the specified index values refer to a column positions. False when they refer to row positions. Ordinal position for the column or row moved in the grid control. New ordinal position for the column or row after it has been moved in the grid control. Converts a column or row index to starting and ending pixels coordinates. True if a column or row exists for the specified index. True when the index is for a column in the grid, False for a row. Ordinal position for the column or row. Position where the column or row starts (pixel). Position where the column or row ends (pixel). Gets the position of the specified column relative to the first column in the grid.

ColumnIndexFromGridColumn is an Integer function used to get the position of the specified column relative to the first column in the grid. The return value contains the difference between Column and FirstGridColumn when Columns have been enabled in the grid control. RealIndex is called to translate the position used in the return value. If Columns have not been enabled, the return value is -1.

ColumnIndexFromGridColumn is used in the implementation of TCustomGrid methods like:

  • ColumnFromGridColumn
  • DoOPExchangeColRow
  • DoOPInsertColRow
  • DoOPMoveColRow
  • DoOPDeleteColRow
Relative position for the specified column. Column number to locate in the grid. Returns the grid column definition at the specified position in Columns.

ColumnFromGridColumn calls ColumnIndexFromGridColumn to convert the relative column number in Column to its ordinal position in the Columns property. It is relative because it refers to the n-th column which is not fixed and is both enabled and visible.

The return value contains the TGridColumn instance in Columns where the Column number was located. The return value is Nil if Column is not a valid relative column number, is not enabled, or is a fixed column on the grid control.

TGridColumn instance at the specified position, or Nil when Column is not a valid or enabled in the grid control. Position in the visible and enabled non-fixed columns for the grid control. Performs actions needed when one or more columns in the grid are changed.

ColumnsChanged is procedure used to perform actions needed when one or more Columns in the grid are changed. AColumn contains the column affected by the change, or signals a change to multiple columns when its value is unassigned (contains Nil).

When AColumn is Nil, the row or column count and/or fixed row or fixed column count has been changed. When AColumn contains a valid TGridColumn instance, the modified column is located in the Columns collection and the VisualChange method is called.

ColumnsChanged is called from methods like: SetFixedCols, SetRowCount, and OnTitleFontChanged. It is also called when the Update method in Columns is called for the TGridColumns collection.

Grid column instance for the notification, or Nil. Performs actions needed when the widths for grid columns have been changed.

ColWidthsChanged has an empty implementation in TCustomGrid. It is not currently used in any descendent classes in the LCL. It can be overridden in custom controls to perform any actions needed when one or more of the column widths has been changed. One common use is to invalidate the grid control and cause it to be redrawn.

ColWidthsChanged is called when a new value is specified for the indexed ColWidths property and Columns have been enabled for the control.

Allocates and configures resources for the Columns collection.

CreateColumns is a TGridColumns function used create a new TGridColumns instance for the grid control. TGridColumn is the class type used for items stored in the collection.

CreateColumns is called from the Create constructor, and the return value is assigned to the member used for the Columns property.

TGridColumns instance created in the method. Checks the values for cached column sizes when they have been reset in the grid.

CheckNewCachedSizes has an empty implementation in TCustomGrid.

Grid cache examined in the method. Creates and configures the widgetset handle for the grid control.

CreateWnd is an overridden method in TCustomGrid. It calls the inherited method to allocate the Handle for the widgetset class.

CreateWnd ensures that internal flags used for horizontal and vertical scroll bar visibility are updated to reflect the states for the control Handle. The CheckPosition method is called to determine the cell selection in the grid. VisualChange is called to refresh the visible area and scroll bars in the control.

TWinControl.CreateWnd TWinControl.Handle
Initializes the window creation parameters with the settings for the control.

CreateParams is a procedure used to initialize and/or update creation parameters in the Params argument. CreateParams is called from the CreateWnd method when the window handle is allocated for the control.

CreateParams is an overridden method in TCustomGrid. It ensures that Params contains the values needed for the style and offset in the window class type.

TWinControl.CreateParams TWinControl.CreateWnd TCreateParams
Creation parameters updated in the method. Performs actions needed when a mouse click occurs in the grid control.

Click is an overridden method used to perform actions needed when a mouse click occurs in the control. The grid control provides an internal flag to suppress mouse click handling when the event occurs in a "hot zone" (fixed header cells for columns or rows). Click checks the value in the internal flag, and calls the inherited method when the click occurs in the "normal" data cells for the grid.

Click is called from methods like SetCol, SetRow, and SetColRow to emulate a mouse click when values are assigned to the Col and/or Row properties.

TControl.Click
Performs actions needed to handle mouse double click events in the control.

DblClick is an overridden method used to perform actions needed when a mouse Double Click event occurs in the grid control.

SelectActive is set to False to ignore an active cell or range selection in the control. The internal TGridState member for the control is set to gsNormal to reflect the new state for the control.

DblClick uses values in the Options property to determine whether double click is enabled for column or row sizing operations in the control. Some of the Options values relevant to DblClick include:

goColSizing
Column sizing in enabled for the control.
goRowSizing
Row sizing is enabled for the control.
goDblClickAutoSize
A mouse double click resizes the column automatically.

When the needed Options values are present, and match the current CursorState for the control, the corresponding action is performed. AutoAdjustColumn is called for a column resize action. RestoreCursor is called, and HeaderSized is called to signal completion of the column resize operation. Row resize actions for double click mouse events are not currently implemented.

If the values in Options or CursorState do not meet the required conditions, the inherited method is called.

TControl.DblClick
Indicates if the DefaultColWidth property is available in component streaming. True when DefaultColWidth contains a positive non-zero value. Indicates if the DefaultRowHeight property is available in component streaming. Returns True if DefaultRowHeight has an explicitly assigned value that is greater than or equal to 0. Defines non-published properties included during LCL component streaming.

DefineProperties is an overridden method used to define non-published properties which are included during LCL component streaming. It sets the read and write routines in Filer used for the following grid properties:

  • ColWidths
  • RowHeights
TControl.DefineProperties
TFiler instance used to read and write the defined properties. Applies an accelerator key for a column in the grid.

DialogChar is an overridden Boolean function used to apply Lazarus messages with accelerator keys for columns in the grid. Message contains the TLMKey instance with the message examined in the method. DialogChar examines each of the Columns defined for the grid to determine if the CharCode for the Message is an accelerator key appearing in the title for the column. When a match is found, the HeaderClick method is called to activate the column.

The return value contains the result from the inherited DialogChar method.

TWinControl.DialogChar
True if the character code in Message is found in a caption for a column on the grid. TLMKey message examined in the method. Performs a comparison between the specified cells in the grid control.

DoCompareCells signals the OnCompareCells event handler (when assigned) to perform the comparison. The return value contains the relative sort order for the compared cells, and uses the following values:

-1
The cell at ACol and ARow occurs comes before the cell at BCol and BRow.
0
The specified cells have the same value.
1
The cell at ACol and ARow occurs comes after the cell at BCol and BRow.

When OnCompareCells is not assigned, the return value is always 0.

Relative sort order for the compared cells. Column number for the cell. Row number for the cell. Column number for the cell. Row number for the cell. Performs actions needed to copy a cell or a text selection to the clipboard.

DoCopyToClipboard is a virtual method in TCustomGrid, and has an empty implementation. It is overridden in descendent classes, like TCustomStringGrid, to perform the actions required for the class type.

DoCopyToClipboard is called from the KeyDown method when the Ctrl+C or Meta+C (macOS, iOS, Darwin) key is handled for the control.

Performs actions needed to cut a cell or a text selection to the clipboard.

DoCutToClipboard is a virtual method in TCustomGrid, and has an empty implementation. It is overridden in descendent classes, like TCustomStringGrid, to perform the actions required for the class type.

DoCutToClipboard is called from the KeyDown method when the Shift+X key is handled for the control.

Performs actions needed when the button for the editor control is clicked.

DoEditButtonClick is a procedure used to perform actions requires when the button for a cell editor or button column is clicked.

ACol and ARow contain the Integer coordinates for the cell where the action occurred.

DoEditButtonClick signals the OnEditButtonClick and OnButtonClick event handlers when they have been assigned for the grid control.

DoEditButtonClick is used in the implementation of the EditButtonClicked method used in cell editor controls, and the MouseUp method.

Column number for the affected cell. Row number for the affected cell. Performs actions needed to hide the cell Editor in the grid control.

DoEditorHide is a procedure used to hide the cell Editor for the control.

When gfEditingDone is included in the GridFlags for the control, and CanFocus indicates that the control can be focused, it is used as the ActiveControl in the parent Form. The Visible property in Editor is set to False to hide the cell editor for the control.

DoEditorHide is called from the EditorHide method.

TCustomForm.ActiveControl TWinControl.CanFocus
Performs actions needed to show the cell Editor for the grid control.

Calls ScrollToCell to position the grid on the cell indicated by the Col and Row properties.

String- and Button-style editor controls are updated to use the alignment defined for the current column. If Columns has not been enabled, the default alignment for the cell is taLeftJustify. Calls EditSetValue to copy the cell content into the cell Editor.

The Editor.SetFocus method is called when the grid control currently has focus and the cell editor can receive focus. InvalidateCell is called to redraw the cell at the position in Col and Row.

DoEditorShow is called from the EditorShow method.

Performs actions needed when the control loses focus.

DoExit is an overridden method in TCustomGrid. It ensures that an active editor control and the active selection are updated when the grid control loses focus.

If the editor for the control is not always visible (goAlwaysShowEditor in Options), InvalidateFocused is called to invalidate the cell or the row. ResetEditor is called to sync and re-display the Editor when needed. SelectActive is set to False when the internal grid state is gsSelecting, and it is reset to gsNormal.

The inherited DoExit method is called to signal the OnExit event handler (when assigned).

DoExit is called from the CMExit method when it handles the corresponding control message.

TWinControl.DoExit TWinControl.OnExit TWinControl.CMExit
Performs actions needed when the grid control receives focus.

DoEnter is an overridden method in TCustomGrid. The inherited DoEnter method is called on entry to signal the OnEnter event handler (when assigned).

It ensures that the active selection and optional editor control are restored when grid control receives focus. If the Editor is not locked for update, and is always visible, the Editor class is re-selected and it is displayed in the active cell. When the Editor is not always visible (goAlwaysShowEditor is not in Options), InvalidateFocused is called to request the active cell or row selection to be redrawn.

DoEnter is called from the CMEnter method when it handles the corresponding control message.

TWinControl.DoEnter TWinControl.OnEnter TWinControl.CMEnter
Signals the OnLoadColumn event handler for the grid control (when assigned).

DoLoadColumn is a method used to signal the OnLoadColumn event handler (when assigned) to load a column from an external XML configuration file. DoLoadColumn is called from the private LoadColumns method, and occurs immediately after a TColumn instance has been created, initialized, and added to the Columns collection. The event handler can be used to override or augment the values loaded from the XML storage into the TColumn instance.

Object (TCustomGrid) for the event notification. Grid column definition for the event. Ordinal position for the column. XML configuration file with the design-time information for the columns in the grid. Version number for the streaming format used in the configuration file. XPath-like expression where the column information is stored. Signals the OnSaveColumn event handler for the grid control (when assigned).

DoSaveColumn is a method used to signal the OnSaveColumn event handler (when assigned) when a column definition is saved to an external XML configuration file.

DoSaveColumn is called from the private SaveColumns method, and occurs immediately after a TColumn instance in the Columns collection is written to the XML storage. It is also called from the SaveContent method when the Columns collection has not been enabled in the control.

Object (TCustomGrid) for the event. Grid column instance for the event handler. Ordinal position in Columns for the grid column. XML configuration file where the column values are stored. Version number for the grid column data written in the XML storage. XPath-like expression where the column information is stored. Handles a mouse wheel operation for the grid control.

DoMouseWheel is an overridden method in TCustomGrid used to apply a mouse wheel operation to the control. It ensures that the SelectActive property is reset to False when MouseWheelOption applies to the selection cursor instead of the visible area for the grid control.

DoMouseWheel calls the inherited method to signal the OnMouseWheel event handler (when assigned), and to apply the mouse wheel movement using the parameter values. The inherited method also determines the return value. It is False if an OnMouseWheel is not found or the message cannot handle the WheelDelta value using DoMouseWheelUp or DoMouseWheelDown.

DoMouseWheel is called from the inherited WMMouseWheel method when the LM_MOUSEWHEEL message is handled for the control.

True when the mouse wheel action was handled for the control. False when a handler was not found or the delta value was invalid. Shift, Alt, Ctrl modifier for the mouse wheel action. Number of units the mouse wheel was moved. A negative values implies movement in the down direction. TPoint instance with the coordinates for the mouse pointer. Handles a mouse wheel down movement for the grid control.

DoMouseWheelDown is a an overridden method in TCustomGrid called when the mouse wheel is scrolled downward. It calls the inherited method on entry to signal the OnMouseWheelDown event handler (when assigned). The return value is set to True if the action was handled in OnMouseWheelDown.

If the action is not handled in OnMouseWheelDown, the GridMouseWheel method is called to scroll to the next selectable area in the control using the specified Shift modifier. When Shift contains ssCtrl (Ctrl key), the horizontal position is updated instead of the vertical. The return value is set to True when the action is handled in this manner.

Use MouseWheelOption to specify whether mouse wheel operations are applied to the grid cursor (selection / editing) or the visible area for the control.

See DoMouseWheelUp for the actions performed when the mouse wheel is scrolled in the upward direction.

DoMouseWheelDown is called from the inherited DoMouseWheel method when an OnMouseWheel event handler was not found, or it did not handle the notification.

TControl.DoMouseWheelDown TControl.OnMouseWheelDown TShiftState
True if the mouse wheel operation was handled in the method. Shift, Alt, Ctrl modifier for the mouse wheel action. TPoint instance with the coordinates for the mouse pointer. Handles a mouse wheel up movement for the grid control.

DoMouseWheelUp is an overridden method in TCustomGrid called when the mouse wheel is scrolled upward. It calls the inherited method on entry to signal the OnMouseWheelUp event handler (when assigned). The return value is set to True if the action was handled in OnMouseWheelUp.

If the action is not handled in OnMouseWheelUp, the GridMouseWheel method is called to scroll to the previous selectable area in the control using the specified Shift modifier. When Shift contains ssCtrl (Ctrl key), the horizontal position is updated instead of the vertical. The return value is set to True when the action is handled in this manner.

Use MouseWheelOption to specify whether mouse wheel operations are applied to the grid cursor (selection / editing) or the visible area for the control.

See DoMouseWheelDown for the actions performed when the mouse wheel is scrolled in the downward direction.

DoMouseWheelUp is called from the inherited DoMouseWheel method when an OnMouseWheel event handler was not found, or it did not handle the notification.

TControl.DoMouseWheelUp TControl.OnMouseWheelUp TShiftState
True if the mouse wheel operation was handled in the method. Shift, Alt, Ctrl modifier for the mouse wheel action. TPoint instance with the coordinates for the mouse pointer. Handles a mouse wheel scroll left message for the control.

DoMouseWheelLeft is an overridden method in TCustomGrid which handles a horizontal mouse wheel scroll message towards the left of the grid control. DoMouseWheelLeft is called from the inherited DoMouseWheelHorz method when an unhandled scroll wheel message with a negative WheelDelta value occurs.

DoMouseWheelLeft calls the inherited method on entry to signal the OnMouseWheelLeft event handler (when assigned). The return value is set to True if the message is handled in the method.

If the message is not handled in the inherited method, the GridMouseWheel method is called using the ssCtrl modifier and the current mouse position as arguments. This is the equivalent of a Ctrl+MouseWheelUp message. The return value is set to True when the message is handled in this manner.

See DoMouseWheelRight for the actions performed for a Ctrl+MouseWheelDown scroll message.

Use MouseWheelOption to specify whether mouse wheel operations are applied to the grid cursor (selection / editing) or the visible area for the control.

TControl.DoMouseWheelLeft
True if the mouse wheel message is handled in the method. Shift, Alt, Ctrl modifier for the mouse wheel action. TPoint instance with the coordinates for the mouse pointer. Handles a mouse wheel scroll right message for the control.

DoMouseWheelRight is an overridden method in TCustomGrid which handles a horizontal mouse wheel scroll message towards the right of the grid control. DoMouseWheelRight is called from the inherited DoMouseWheelHorz method when an unhandled scroll wheel message with a positive WheelDelta value occurs.

DoMouseWheelRight calls the inherited method on entry to signal the OnMouseWheelRight event handler (when assigned). The return value is set to True if the message is handled in the method.

If the message is not handled in the inherited method, the GridMouseWheel method is called using the ssCtrl modifier and the current mouse position as arguments. This is the equivalent of a Ctrl+MouseWheelDown message. The return value is set to True when the message is handled in this manner.

See DoMouseWheelLeft for the actions performed for a Ctrl+MouseWheelUp scroll message.

Use MouseWheelOption to specify whether mouse wheel operations are applied to the grid cursor (selection / editing) or the visible area for the control.

TControl.DoMouseWheelRight
True if the mouse wheel message is handled in the method. Shift, Alt, Ctrl modifier for the mouse wheel action. TPoint instance with the coordinates for the mouse pointer. Performs actions to automatically apply the layout policy with the specified scaling factors.

DoAutoAdjustLayout is an overridden method in TCustomGrid.

AMode contains the layout policy applied in the method, and contains a value from the TLayoutAdjustmentPolicy enumeration. AXProportion and AYProportion contain the horizontal and vertical scaling factors applied for the specified layout policy.

DoAutoAdjustLayout calls the inherited method on entry to apply the scaling factors for the grid control. This includes scaling its width and/or height using values in Align and/or Anchors. The BaseBounds for the control may also be affected.

When AMode contains lapAutoAdjustWithoutHorizontalScrolling or lapAutoAdjustForDPI, the layout policy is applied to the columns and rows in the control. When Columns has been enabled the factor in AXProportion is applied to MinSize, MaxSize and the stored Width for each of the TGridColumn entries. AXProportion is also applied to the values in Cols and DefaultColWidth.

The value in AYProportion is applied to the values stored in Rows and DefaultRowHeight.

DoAutoAdjustLayout is called from the inherited AutoAdjustLayout method.

Auto-adjust layout policy applied in the method. Horizontal scaling factor for the layout policy. Vertical scaling factor for the layout policy. Signals OnChangeBounds event handlers for the control.

DoOnChangeBounds is an overridden method in TCustomGrid. It calls the inherited method on entry to signal any assigned OnChangeBounds event handlers and to update flag values for the control.

DoOnChangeBounds updates cached column and row sizes, and scroll bar information when the bounds for the control have been changed.

TControl.DoOnChangeBounds
Performs a delete operation for a column or a row.

DoOPDeleteColRow is a method which performs actions needed to delete the specified column or row from the grid control.

IsColumn indicates whether a column or row is affected in the method. When set to True, the specified column number is deleted from the control. Otherwise, the specified row number is removed.

Use Index to specify the position for the column or row removed in the method.

Prior to removing the specified column or row, private methods are called to validate values used by or affected in the operation like:

Index
Checks whether the value in Index is a valid column or row number. An EGridException exception is raised if Index has an invalid index value for the grid control.
FixedCols, FixedRows
Ensures that new fixed column or row counts are valid for the number of columns or rows on the grid control. An EGridException is raised if the new values are not within the limits for the column or row count.
Col, Row, ColCount, RowCount
Ensures that values for Col or Row are range limited to the new column or row count for the control. Calls MoveNextSelectable to scroll the grid control to the new origin cell when needed.

DoOPDeleteColRow ensures that a visible cell editor in the column or row is deactivated by setting EditorMode to False.

The ColRowDeleted method is called when the affected data has been removed from the grid control and the cached values in GCache. In a descendent class (TCustomDrawGrid), the the OnColRowDeleted event handler is signalled (when assigned).

Col and Row are updated if the operation causes the selection range to be changed, and SelectCell is called to include the cell in Selection. Sizes for auto-filled columns are recalculated when needed. The cell Editor is updated when needed for the new selection and position on the grid control.

True if Index refers to a column instead of a row. Position for the column or row deleted in the method. Performs an exchange of values for the columns or rows with the specified indexes.

DoOPExchangeColRow is used to exchange or swap column or row values at the specified positions in the grid control.

IsColumn indicates whether columns or rows are affected in the method. When set to True, Index and WithIndex refer to column positions. Otherwise, they refer to row positions.

TGridColumn instances in Columns are exchanged when the collection has been enabled in the control. Column widths in Cols, or row heights in Rows are also exchanged in the method.

DoOPExchangeColRow calls the ColRowExchanged method to perform the notification which informs the grid control to exchange their column or row data.

AdjustEditorBounds is called to reposition the cell Editor for the grid when the operation requires it to be moved.

When a value in Index or WithIndex is a sort column for the grid, the value in the SortColumn property is updated to reflect the (ex)changed value.

DoOPExchangeColRow is called from the Sort method when the StrictSort property is set to False.

True if Index refers to a column instead of a row. Position for a column or row exchanged in the method. Position for the other column or row exchanged in the method. Performs an insert operation for a column or a row at the specified position. True if Index refers to a column instead of a row. Position where the column or row is inserted in the method. Performs a move operation for the column or row at the specified position.

DoOPMoveColRow is called from the MouseUp method when the mouse button is released during a column or row drag operation.

DoOPMoveColRow ensures that FromIndex and ToIndex contain valid index values for the grid. When FromIndex and ToIndex contain the same value, the drag operation has ended without changing the position for the column or row. In this situation, the grid control is redrawn and no additional actions are performed in the method.

IsColumn determines whether column or row data is affected in the method. When set to True, the index values refer to column positions on the grid. Otherwise, the index values refer to row positions.

Column Movement

Column movements are handled using either the Columns collection or the internal list of column widths maintained in the grid control. When Columns has been enabled, and column order is not locked using GridFlags, the MoveColumn method in the collection is used to move the specified column to its new position.

If Columns have not been defined, the internal column list is used to perform the operation. ColRowMoved is called to perform an event notification (implemented in descendent classes) when the action has been completed.

Row Movement

Row movements are handled using the internal list of row heights in the control. The Move method in in the list is called to relocate the specified row to its new position. ColRowMoved is called to perform an event notification (implemented in descendent classes) when the action has been completed.

DoOPMoveColRow calls AdjustEditorBounds to re-select the active cell and position an active cell editor (when needed). For a column movement, the value in SortColumn is updated to reflect the new position for the sort column.

True if index values are for columns instead of rows. Ordinal position for a column or a row moved in the method. Ordinal position where the column or row is relocated in the method. Pastes data from the clipboard into the grid control.

DoPasteFromClipboard is a virtual method and has an empty implementation in TCustomGrid. It must be overridden in a descendent class to use the data and selection ranges(s) allowed in the implementation.

DoPasteFromClipboard is called from the KeyDown method when a Shift+V key is handled for the control.

Performs actions needed to prepare the canvas for a drawing operation.

DoPrepareCanvas signals the OnPrepareCanvas event handler (when assigned) to prepare the Canvas to draw the specified cell using the specified state. It is called from the PrepareCanvas method, and allows the default actions performed in the caller to be overridden.

Column number for the current cell. Row number for the current cell. Drawing state (like selected, focused, fixed) for the current cell. Performs actions needed when the grid control is resized.

DoOnResize is an overridden method in TCustomGrid. It calls the inherited method on entry to signal the OnResize event handler(s) assigned to the control or its parents. If the active update counter is 0, the Invalidate method in the widgetset class instance is called to refresh the control.

DoOnResize is called from the Resize method in the ancestor class.

TControl.DoOnResize TControl.OnResize TControl.Resize
Captures the current client width prior to setting the new bounds for the control. TControl.DoSetBounds New value for the Left property. New value for the Top property. New value for the Width property. New value for the Height property. Applies a UTF-8-encoded character to the active cell editor in the control.

DoUTF8KeyPress is an overridden method used to apply the UTF-8-encoded character in UTF8Key to the active cell Editor for the control. The return value is True if the character is successfully handled.

DoUTF8KeyPress calls the inherited method on entry to determine if the character is handled in the ancestor class. No additional actions are performed in the method when the character is handled in the ancestor.

Otherwise, EditingAllowed is called to determine if a cell editor can be displayed for the column number in Col. When allowed, the EditorShowChar method is called to apply the value in UTF8Key to the cell Editor. The value in UTF8Key is set to an empty string (''), and the return is set to True on successful completion of the operation.

TWinControl.DoUTF8KeyPress
True if the character was successfully applied in the method. UTF-8 character value handled in the method. Draws the border for the grid control.

DrawBorder is used to draw the border around the grid using the client rectangle for the control. No actions are performed in the method when Flat is set to False or BorderStyle has a value other than bsSingle.

DrawBorder ensures that the Pen color in Canvas is updated to use the value in BorderColor. The width for the Pen is set to 1 pixel for the drawing operation. Drawing methods in Canvas are called to draw the borders on the Left, Right, Top, and Bottom edges for the control.

DrawBorder is called from the Paint method, and occurs after the inherited Paint method and its OnPaint event handler have been executed.

TCustomControl.Canvas TControl.ClientHeight TControl.ClientWidth
Draws all of the rows for the grid.

Draws both the fixed rows and any visible data rows using cached information in the grid control. Calls DrawRow to render each row by its row number in the control.

DrawAllRows is called from the Paint method.

Draws the fill rectangle on the specified canvas.

Shifts the specified rectangle by one pixel on the left- and right-hand edges when UseRightToLeftAlignment is set to True. Calls the FillRect method in the TCanvas instance to draw the adjusted rectangle.

DrawFillRect is called from the DrawCell method.

Canvas where the fill rectangle is drawn. Rectangle with the bounds filled in the method. Draws a cell using a given state at the specified grid location (Col, Row, rectangle).

Calls PrepareCanvas to initialize the Canvas for the control to the state in AState. Calls DrawFillRect to fill the rectangle in ARect using the background for the cell. Calls DrawCellGrid to render fixed or non-fixed cells using the state in AState, including horizontal and vertical grid lines when enabled.

DrawCell is called from the DrawRow method when it renders the visible cells in the grid row.

TCustomControl.Canvas
Column number for the cell. Row number for the cell. Rectangle with the dimensions for the cell. State used to render the cell. Draws cell grid lines for the control.

DrawCellGrid is a procedure used to draw cell grid lines for both a fixed and a non-fixed cell in the grid control.

DrawCellGrid ensures that the control Canvas (and its Pen) are updated to use the values needed to draw the fixed or non-fixed cell at the location specified in ACol and ARow.

For a fixed cell (when gdFixed is in AState), grid lines are drawn when gdoFixedVertLine or gdoFixedHorzLine is found in the Options property. The Pen in the control Canvas is updated to reflect a non-zero value in GridLineWidth.

When Flat is set to False, the value in AState is used to determine the color used for the Pen. Canvas drawing methods, like MoveTo and LineTo, are used to draw the cell grid lines at the coordinates in ARect. The value in UseRightToLeftAlignment determines how values in ARect are adjusted for the operation.

When Flat is set to True, the value in FixedGridLineColor is used as the color for the Pen.

For a non-fixed cell (gdFixed is not in AState), grid lines are drawn when gdoVertLine or gdoHorzLine is found in the Options property. The Pen in the control Canvas is updated to use the GridLineWidth, GridLineStyle, and GridLineColor for the control. Canvas drawing methods, like MoveTo and LineTo, are used to draw the cell grid lines at the coordinates in ARect. The value in UseRightToLeftAlignment determines how values in ARect are adjusted for the operation.

DrawCellGrid is called from the DrawCell method after preparing the Canvas and drawing the filled rectangle with the background for the cell.

TControl.UseRightToLeftAlignment
Column number for the cell. Row number for the cell. Rectangle with the screen coordinates for the cell. State for the cell (normal, fixed, pushed, et. al.). Draws the text for a non-fixed cell in the grid.

The implementation for DrawTextInCell is empty in TCustomGrid. It is overridden in descendent classes.

Column number for the cell drawn in the method. Row number for the cell drawn in the method. Rectangle with the coordinates where the cell text is drawn. Drawing state for the cell (like selected, focused, fixed, etc.). Draws a cell using the theme services for the specified grid drawing state.

DrawThemedCell is a procedure used to draw the cell at the specified coordinates using the theme services for the platform or widget set.

aCol contains the column number for the affected cell.

aRow contains the row number for the affected cell.

aRect contains the screen coordinates for the cell rendered in the method.

aState contains the grid drawing state applied to the cell. aState contains a value from the TGridDrawState enumeration that determines the theme service element details used for the drawing operation.

Grid Draw State Theme Element Description
gdPushed thHeaderItemPressed Draws the cell using the Pressed state
gdHot thHeaderItemHot Draws the cell using the Hotlighted state
Other states thHeaderItemNormal Draws the cell using the normal drawing state
Column number for the affected cell. Row number for the affected cell. Screen coordinates for the cell. Grid drawing state for the cell. Draws the specified text in the given text rectangle.

DrawCellText is a procedure used to draw the text specified in AText using the given text rectangle on the Canvas for the control. The Canvas also contains the alignment and layout used for the text drawn in the method.

ARect contains the Canvas coordinates for the text is drawn. DrawCellText adjusts the bounds in ARect to account for the cell padding used in the control (varCellPadding) as needed for the text alignment and layout. The TextRect method in the Canvas is called to render the text.

Values in the ACol, ARow, and AState parameters are not used in DrawCellText.

DrawCellText is used in the implementation of the DrawColumnText, DrawCellAutonumbering, and DrawTextInCell methods where AText contains the column title, row number, or content for a given cell.

Not used in the current implementation. Not used in the current implementation. Text rectangle for the text drawn on the control canvas. Not used in the current implementation. Text drawn in the method. Draws a check box bitmap which represents the given state in a cell.

DrawGridCheckboxBitmaps is used to draw a bitmap used for a check box at the cell coordinates in ACol and aRow. AState contains the check box state for the cell, and determines the image displayed in the specified cell.

GetImageForCheckBox is called to get the image list, image index, and/or bitmap used in the cell. Use the OnUserCheckBoxImage or OnUserCheckboxBitmap event handler to get a custom image or bitmap displayed for the value in AState. If GetImageForCheckBox is unable to find either a bitmap or an image, ThemeServices is used to get the theme element details for the check box state.

The bitmap/image/theme element may be scaled if the control Font uses a display density (PPI) different than the value used for the Screen.

When Columns has been Enabled, the GetColumnAlignment and GetColumnLayout methods are used to determine the image alignment and layout used for the check box cell. If Columns has not been enabled, the image is centered horizontally in the cell using the vertical alignment defined for text on the Canvas.

DrawGridCheckboxBitmaps adjusts ARect to use the cell padding for the control (varCellPadding) along with the size, alignment and layout needed for the grid column.

The check box bitmap is drawn using the mechanism needed for the image source; ThemeServices.DrawElement, Canvas.StretchDraw, or TScaledImageListResolution.StretchDraw.

DrawGridCheckboxBitmaps is called from the DrawCellCheckboxBitmaps method.

Column number for the check box cell. Row number for the check box cell. Rectangle with the bounds for the cell. Checkbox state used to determine the bitmap drawn in the cell. Draws a cell in a button-style column.

DrawButtonCell is a method used to draw a cell which appears in a button-style column. DrawButtonCell uses ThemeServices to get the theme element details used to render the button for the cell.

AState contains the drawing state for the button, and determines the theme element details used for the drawing state. The ThemeServices.DrawElement method is called to render the button on the control Canvas at the location specified in ARect.

DrawButtonCell is called from DefaultDrawCell when the column has a button-style definition.

Column number for the button cell. Row number for the button cell. Rectangle with the bounds where the button is drawn. Drawing state for the button cell; pushed, hot, or normal. Draws a column or row when dragging is in effect. Draws the text and image for a grid column title at the specified cell coordinates.

DrawColumnText is a method used to draw the text and image for a grid column title at the cell coordinates specified in ACol and ARow. DrawColumnText calls DrawColumnTitleImage to draw the sort indicator for the column. DrawCellText is called to render the text for the cell using the specified drawing state.

DrawColumnText is called from the DefaultDrawCell method in descendent classes for cells which are fixed column titles.

Column number for the column title. Row number for the column title. Rectangle with the bounds for the column title. Drawing state for the text in the cell. Draws the image(s) used in the column title at the specified index in the grid.

DrawColumnTitleImage is a method used to draw the image(s) used in the column title at the index position in AColumnIndex. ARect contains the bounds for the cell where the image is drawn.

When AColumnIndex contains the same value as the SortColumn property, a sort indicator is drawn for the column. GetSortTitleImageInfo is called to determine whether theme services is used to drawn native sort buttons using theme element details. The image size may be scaled when the display density (PPI) for the control Font has a value other than 96.

DrawColumnTitleImage ensures that image padding (DEFIMAGEPADDING) is applied to the bounds in ARect. The top and bottom bounds are adjusted so that the image is vertically centered in the area in ARect.

DrawColumnTitleImage calls the DrawElement method in ThemeServices to draw the sort indicator.

When native sort indicators are not used for the column, an image scaled to the display density is retrieved from the image list. DrawColumnTitleImage ensures that image padding (DEFIMAGEPADDING) is applied to the bounds in ARect. The top and bottom bounds are adjusted so that the image is vertically centered in the area in ARect. The Draw method in the scaled image resolution is called to draw the image on the control Canvas.

TitleImageList is used to determine if an additional image is displayed for the column at AColumnIndex. When TitleImageList has been assigned, the GetTitleImageInfo method is called to get the image list and position used for the column. When an image is defined in Columns, an image scaled to the size size needed for the display density (PPI) is retrieved from TitleImageList. The bounds in ARect is adjusted to include padding around the image (DEFIMAGEPADDING) using the image layout for the column. The Draw method in the scaled image resolution is called to render the image to the control Canvas.

DrawColumnTitleImage is called from the DrawColumnText method.

Rectangle with the bounds for the column title. Column Index for the title image drawn in the method. Draws the edges (and filled background) of the client area for the control. Draws the focus rectangle for the specified cell.

DrawFocusRect has an empty implementation in TCustomGrid. It is overridden in descendent classes.

Column number for the cell. Row number for the cell. TRect instance with the bounds for the cell. Draws the columns for the specified row in the grid control.

DrawRow is a method used to draw the columns for the row number specified in ARow. DrawRow calls ColRowToOffSet to get the upper and lower bounds for the row, and ensures that the bounds are within the clipping area for the control Canvas.

No actions are performed in the method when the client area for the row does not fit within the clipping rectangle for the control Canvas.

DrawRow iterates over the columns in the visible area in the grid to determine if each cell fits vertically within the clipping rectangle for the control Canvas. If column spanning (goColSpanning) has been enabled in the Options for the grid, the cell extent is determined for each cell. DoDrawCell is called to render the cells.

DrawRow draws the focus rectangle for the row when row selection (goRowSelect) is enabled in the Options for the grid control. DrawFocusRect is called to render the focus rectangle.

DrawRow draws fixed cells used for title columns when the row is one of the fixed rows.

DrawRow is called from the DrawAllRows method.

Row number drawn in the method. Signals the OnEditButtonClick or OnButtonClick event handler (when assigned).

When Sender is the TButtonCellEditor for the control, the DoEditButtonClick method is called using the Col and Row numbers from the TButtonCellEditor class instance. Otherwise, DoEditButtonClick is called using the values in the Col and Row properties.

Object for the event notification. Gets the value for the cell Editor.

EditorDoGetValue creates a GM_GETVALUE TGridMessage with the Col, Row, and value for the cell. It is dispatched to the Editor for the control. SetEditText is called prior to exiting from the method; not used in TCustomGrid - but relevant in descendent classes with an event handler for the action.

Resets the value in the selected cell when a visible editor is cancelled or hidden. Sets the mask and value for a visible cell editor in the grid control. Returns True if the Editor is able to accept the specified UTF-8 character.

Always returns True in TCustomGrid. It is overridden in descendent classes like TCustomDbGrid.

TCustomDBGrid.EditorCanAcceptKey
True the active cell editor can accept the specified UTF-8 character. UTF-8 character examined in the method. Determines if the current column number is defined as read-only.

Calls GetColumnReadonly using the value in Col as the column number.

When the Columns collection has been enabled, the ReadOnly property in the TGridColumn instance determines the return value. Otherwise, the value from GetDefaultColumnReadOnly is used as the return value (False in TCustomGrid).

True if the current column is marked (or defined) as read-only. Hides a visible cell editor in the grid control.

EditorHide ensures that an active, visible cell editor is locked / hidden / unlocked in the method. No actions are performed in the method when EditorLocked returns True, or the Editor is not visible.

EditorHide sets the value in EditorMode to False, and sets GridState to gsNormal.

No additional actions are performed when the Editor does not have a Parent (when the parent form is closing). If the Editor has an assigned Parent, the Editor is locked and DoEditorHide is called to hide the Editor. If the Editor was focused on entry, SetFocus is called to restore focus to the grid control. The editor is unlocked prior to exiting from the method.

Returns True if the Editor is locked, i.e. unable to accept input or make changes. True when LockEditor has been called and UnLockEditor has not yet been called. Indicates if the grid and specified column allow editing.

Returns True if both the grid and the specified column allow editing. The return value is True when all of the following conditions are satisfied:

  • goEditing is included in the Options property
  • ACol contains a valid column index
  • RowCount has a value larger than the value in FixedRows
  • The Columns collection has been Enabled (contains at least one visible column)
  • A TGridColumn instance exists for the column index in ACol
  • The TGridColumn instance is not marked as read-only
Returns True if both the grid and the current column allow editing. Column number examined in the method. Performs actions to select the entire content in the current cell.

EditorSelectAll is a method used to select the entire content in the current cell when the Editor is active and visible. EditorSelectAll creates, configures, and dispatches a TGridMessage using the GM_SELECTALL message constant to the Editor in the grid control.

No actions are performed in the method when Editor has not been assigned (contains Nil).

EditorSelectAll is called from the EditorShow method when its SelAll argument is set to True, and from the IMEStartComposition method.

Displays the Editor for the selected cell.

Displays and enables the cell Editor for the selected cell, and optionally selects all content in the cell.

No actions are performed in the method at design-time, or during LCL component streaming. The grid control must have an allocated Handle, and be Enabled and Visible (including the Parent). In addition, both the grid and the column must allow editing. Use Options to enable editing in grid cells. Use Columns to define TGridColumn instances with editable columns using the required button style for the column data.

No actions are performed in the method when Editor has not been assigned, or has already been displayed, or is currently locked by a call to LockEditor.

EditorShow sets the value in EditorMode to True, and saves the existing cell value on entry. EditorShowing is set to True to indicate that the Editor is visible, and calls doEditorShow to display the Editor control.

SelAll indicates whether all of the content in the current cell is selected in the Editor for the control. When set to True, the EditorSelectAll method is called to post the GM_SELECTALL message to the Editor control. The value in GridState is set to gsNormal prior to exiting from the method.

EditorShow is called when the value goAlwaysShowEditor is included in the Options for the grid control. It is also called from methods like:

  • ResetEditor
  • MouseDown
  • MouseUp
  • DoEnter
  • KeyDown
  • KeyPress
  • MoveExtend
  • MoveNextSelectable
  • EditorShowInCell
  • EditorShowChar
  • EditorSetMode
True to select the entire content for the cell in the Editor. Shows the cell content for the Editorin situ. Not used in the current implementation. Column number where the editor is displayed. Row number where the editor is displayed. Performs actions needed when the width for a cell Editor has been changed.

EditorWidthChanged performs actions needed to update the width for the cell Editor when a column width in the grid has been changed. EditorWidthChanged calls the EditorPos method to set the position, bounds, and font for the Editor.

EditorWidthChanged is called when a new value is assigned to the indexed ColWidths property, and when column widths are adjusted when AutoFillColumns is set to True.

Column number for the affected editor. New width for the cell with the editor control. Gets the position of the first column after any fixed columns in the grid.

FirstGridColumn is an Integer function used to get the ordinal position of the first column appearing after any fixed column in the grid control. The return value contains the value in the FixedCols property.

FirstGridColumn is used in the implementation of methods including:

  • GetColWidths
  • GetIsCellTitle
  • ColumnIndexFromGridColumn
  • GridColumnFromColumnIndex
  • ColumnsChanged
Position of the first column after any fixed columns in the grid. Determines if all columns or all rows in the grid are fixed.

FixedGrid is a Boolean function used to determine whether all columns in the grid are defined as fixed columns, or all rows are defined as fixed rows. The return value is True when FixedCols is equal to ColCount OR FixedRows is equal to RowCount.

FixedGrid is used in the implementation of methods like: SetFixedCols, SetFixedRows, MouseToGridZone, MouseDown, MouseMove, MouseUp, TryMoveSelect, EditorAlwaysShown, and FixPosition.

True when all of the row or all of the columns in the control are fixed. Performs actions needed when the font for the control is changed.

FontChanged is an overridden method used to perform actions needed when the Font for the control has been changed.

FontChanged ensures that the internal default heights for rows and columns are reset to 0 (zero). This causes the default column and row heights to be recalculated when the DoAutoAdjustLayout method is called.

When csCustomPaint is included in ControlState, the Font is assigned to the Canvas for the control.

Otherwise, the FontChanged method is called for the ancestor class and the Columns collection (when Enabled). If the default title font is used for the control, the Font is assigned to TitleFont property.

FontChanged is assigned as the OnChange event handler for the Font property in the constructor for the class instance.

TControl.Font TControl.ControlState TCustomControl.FontChanged TFont
Object for the event notification. Gets auto-fill information for the specified column.

GetAutoFillColumnInfo is a method used to get sizing information for an auto-fill column specified in Index. AMin, AMax, and APriority are variable arguments updated with the values for the requested column.

GetAutoFillColumnInfo calls ColumnFromGridColumn to get the TGridColumn instance in Columns with the requested values. If a column exists with the requested Index, its properties are stored in the variable parameters. When Index is a fixed column in the grid, the value in APriority is set to 0 (zero) which disables auto-sizing for the column. If Columns has not been Enabled for the control, or the column index is not valid, APriority is set to 1.

GetAutoFillColumnInfo is called when AutoFillColumns is set to True, and the column sizes are recalculated for the the grid control.

Position for the grid column examined in the method. Minimum size for the column. Maximum size for the column. Sizing priority for the column. Gets the hint for the specified cell using the Options enabled in the grid control.

GetCellHintText signals the OnGetCellHint event handler (when assigned) to get the hint text for the cell at the position in ACol and ARow. The return value contains the hint text returned from the event handler, or an empty string ('') when the event handler has not been assigned.

GetCellHintText is called from the ShowCellHintWindow method when Options contains the value goCellHints and CellHintPriority is not set to chpTruncOnly.

String with the hint text for the specified cell. Column number for the cell. Row number for the cell. Gets the cell content at the specified column and row numbers.

Always returns an empty string ('') in TCustomGrid. Overridden in descendent classes.

Content for the specified cell. Column number for the cell. Row number for the cell. Gets the horizontal Alignment for the specified column.

Calls ColumnFromGridColumn to get the TGridColumn instance in Columns for the column number in the Column parameter.

ForTitle indicates the alignment used as the return value for the specified column number. When set to True, the alignment for the Title in the TGridColumn instance is used as the return value. Otherwise, the alignment property in the TGridColumn instance is used as the return value.

Called from the PrepareCanvas and DrawGridCheckboxBitmaps methods.

TAlignment value for the column. Column number examined in the grid. True when the alignment in the column title is used. Gets the Color used to render the background for the specified column number.

GetColumnColor ensures that the correct color value is used to render the background for the specified column number.

When the Columns collection has been enabled, the color is retrieved from the TGridColumn instance. The Color property in TGridColumn is used when ForTitle is set to False. Otherwise, the Color in the Title for the column instance is used.

If the Columns collection has not been enabled, the color is retrieved from the Color or FixedColor properties in the grid control. FixedColor is used when ForTitle is set to True.

GetColumnColor is called from the PrepareCanvas method.

Use properties like AlternateColor, FixedHotColor, FocusColor, and SelectedColor to control when the corresponding Options are enabled for the grid control.

Color the column. Column number examined in the method. True when the color for the title in the column is needed. Gets the font used to render values for the specified column. TControl.Font TFont instance used to render values for the column. Column number examined in the method. True when the font for the column title is needed. Gets the vertical text Layout value for the specified column. TTextLayout value for the column. Column number examined in the method. True when the text layout for the column title is needed. Returns True if the column is marked as ReadOnly. Returns True if the column is marked as ReadOnly. Column number examined in the method. Gets the text displayed as the column title for the specified column number.

GetColumnTitle is a String function used to get the text displayed as the column title for column number specified in Column. ColumnFromGridColumn is called to get the non-fixed TGridColumn instance at the specified position in the Columns collection.

If a column exists at the position in Column, the Caption stored in its Title property is used as the return value. If Column does not represent a valid non-fixed column position, or the Columns collection has not been enabled, the value from the GetDefaultColumnTitle method is used as the return value.

GetColumnTitle is called from the DrawColumnText method when the image and text for the column header is drawn.

Text displayed in the title for the column. Column number for the title text. Gets the width of the column at the specified column number.

GetColumnWidth calls ColumnFromGridColumn to get the TGridColumn instance for the column number in the Column parameter. If the grid column is assigned, its Width property is used as the return value for the method.

The grid column may be unassigned (contain Nil) if Column is not a valid column number for the control, or Columns has not been Enabled for the grid. In this situation, GetDefaultColumnWidth is called to get the return value for the method.

GetColumnWidth is never called in TCustomGrid or TCustomDrawGrid. It is called from the internal auto-sizing routine in the TCustomDBGrid descendant.
Width (in pixels) for the column. Column number examined in the method. Returns the relative cell coordinates for the next cell in the grid navigation order.

AAutoAdvance contains the navigation direction requested in the method. When it is set to aaNone, the values in ACol and ARow always contain 0 (zero) indicating no relative movement.

When Inverse is set to True, the cell navigation order in AAutoAdvance is reversed. When row selection is enabled in the grid Options (using goRowSelect), ACol is set to the first non-fixed column in the grid. Otherwise, it is set to the last column in the grid. Other auto-advance values are handled as follows:

  • aaLeft is treated as if it were aaRight
  • aaRightDown is treated as if it were aaLeftUp
  • aaLeftDown is treated as if it were aaRightUp
  • aaRightUp is treated as if it were aaLeftDown
  • aaLeftUp is treated as if it were aaRightDown

The next cell for the navigation order is calculated and returned in the ACol and ARow arguments. The return value is True if the values in ACol and ARow were successfully selected as the current cell in the grid.

True if the calculated cell for the movement is selected in the grid control. True is the navigation order is reversed. Column number after the navigation request. Column number after the navigation request. Direction of movement for the request. Gets the default horizontal alignment used for values in the grid control.

GetDefaultColumnAlignment is a TAlignment function which provides the default horizontal alignment for text in the columns for the grid control. It is used in the GetColumnAlignment method when Columns are not Enabled for the control. GetDefaultColumnAlignment returns the Alignment value from DefaultTextStyle as stored in the constructor for the class instance.

TAlignment
Default horizontal alignment for the specified column. Column number is not used in the method Gets the default width used for the specified column.

GetDefaultColumnWidth is an Integer function which retrieves the default width for the specified Column in the grid control. GetDefaultColumnWidth is used in the GetColumnWidth method when Columns have not been enabled for the control. It returns the value stored in the DefaultColWidth property.

Use the indexed ColWidths property to set the width for an individual column when the Columns collection has not been enabled. Or, use the Columns collection to maintain column definitions including their editing and display attributes.

Default column width for the specified column number. Column number. Ignored in the method. Gets the default vertical layout for text in the specified column.

GetDefaultColumnLayout gets the default vertical layout for text in the specified Column. The DefaultTextStyle property is used as the source for the text Layout, and contains the value assigned in the constructor for the class instance.

GetDefaultColumnLayout is called from GetColumnLayout when a TGridColumn instance cannot be located in Columns for the specified column number. This occurs when Column is invalid for the defined Columns in the control, or when Columns has not been Enabled (contains at least one visible column).

Change values in the DefaultTextStyle property to override the default values assigned in the Create method. Use the Columns collection to change the text layout used in a column when Columns are Enabled.

TTextLayout value for the specified column. Column number examined in the method. Gets the default setting for the ReadOnly flag in the specified column number. TCustomDBGrid.GetDefaultColumnReadOnly TField.ReadOnly Always returns False in TCustomGrid; overridden in descendent classes. Ordinal position for the column definition examined in the method. Gets the default text used as the column title for the specified column number.

GetDefaultColumnTitle provides the text used for the specified column number when Columns have not been enabled for the grid control. GetDefaultColumnTitle always returns an empty string ('') in TCustomGrid.

GetDefaultColumnTitle is called from the GetColumnTitle method.

Default text used as the column title for the specified column. Column number for the default title text. Gets the default cell editor for the specified column.

GetDefaultEditor is a TWinControl function used to get the default Editor control for the specified column number.

GetDefaultEditor calls EditingAllowed to determine if the column can be edited. When editing is permitted, the Columns collection is used to get the ButtonStyle stored in the TGridColumn instance. If the column uses the cbsAuto button style and has a valid non-empty PickList, the cbsPickList button style is used.

If Columns has not been enabled, the cbsAuto button style is always used for the Editor control.

GetDefaultEditor calls EditorByStyle to create the Editor with the button style needed for the control. The return value is Nil if the column does not allow editing, or the current cell is a fixed column or row header.

For an Editor using the cbsPickList button style, its items and drop-down row count are set using values from the column definition in Columns.

GetDefaultEditor is called from the SelectEditor method prior to selecting the cell and signalling the OnSelectEditor event handler (when assigned). Use the OnSelectEditor event handler to override the Editor style or its configuration.

The control used as the Editor for the specified column number. Column number examined in the method. Gets the default height for a row in the grid control.

GetDefaultRowHeight is an Integer function used to get the default height for a row in the grid control.

GetDefaultRowHeight uses a TCanvas instance to get the height for the text displayed in a row. If the control Canvas is unassigned, or does not have an allocated handle, a temporary TCanvas instance is created using the Font for the control. The TextHeight method in Canvas is called to get the return value for the method.

GetDefaultRowHeight is called from the GetDefRowHeight method used to get the value for the DefaultRowHeight property.

What are the 7 additional pixels added to the text height?
Default value used as the height for rows in the grid. Gets the grid drawing state for the cell with the specified column and row numbers.

GetGridDrawState is a TGridDrawState function used to get the state flags for the cell specified in ACol and ARow. The return value can contain the following enumeration values:

gdFixed
ARow is one of the FixedRows for the grid.
gdFocused
ACol and ARow have the same values as the Col and Row properties.
gdSelected
ACol and ARow have the same values as the Col and Row properties, or the cell is included in a selection range.
gdRowHighlight
Row highlighting is enabled in Options, Row and aRow have the same value, and the cell is not a fixed cell.
gdPushed
ACol and ARow match the cached PushedCell coordinates.
gdHot
ACol and ARow match the cached HotCell coordinates, and the cell is not "pushed".

GetGridDrawState is called from the DrawRow and ShowCellHintWIndow methods.

TGridDrawState instance with the state flags for the specified cell. Column number for the cell examined in the method. Row number for the cell examined in the method. Gets the bitmap used to draw check box columns in the grid.

GetImageForCheckBox signals the OnUserCheckboxBitmap event handler (when assigned) to get a bitmap used for the check box state. If a valid TBitmap instance is not assigned in the event handler, the OnUserCheckBoxImage event handler is signalled (when assigned) to get the TImageList, TBitmap, and ImageIndex used for the purpose.

GetImageForCheckBox is used in the implementation of the DrawGridCheckboxBitmaps and DrawCellText methods in TCustomGrid.

Column number for the check box cell. Row number for the check box cell. Checkbox state for the cell. Image list with images used for check box drawing states. Ordinal position of the image used for the corresponding check box state. Bitmap with the image drawn for the check box state. Gets the position for the specified scroll bar.

GetScrollBarPosition is an Integer function used to get the position for the scroll bar specified in Which. GetScrollBarPosition calls the GetScrollInfo routine in the LCL interface to get the TScrollInfo structure with the position for the scroll bar in Which.

The return value contain the position from the TScrollInfo structure. The return value is 0 (zero) if the Handle for the grid control has not been allocated.

GetScrollInfo TScrollInfo
Current position in the specified scroll bar. Indicates the scroll bar (horizontal or vertical) examined in the method. Gets the smooth scroll setting in the Options for the grid. GetSmoothScroll determines whether the smooth scroll setting (goSmoothScroll) has been included in the Options for the grid control. Needs an explanation of what "smooth scroll" really means. True when Options contains the value goSmoothScroll. Not used in the current implementation. Gets the values for the scroll bar visibility flags in the control. ? True if the horizontal scroll bar is visible. True if the vertical scroll bar is visible. Gets the range values for the scroll bars when visible.

Called from the CalcScrollbarsRange method when the grid has been scrolled or when a size value in ColWidths has been changed.

True if the horizontal scroll bar is visible and updated in the method. True if the vertical scroll bar is visible and updated in the method. Returns the horizontal scroll bar range, or 0 when the scroll bar is not visible. Returns the vertical scroll bar range, or 0 when the scroll bar is not visible. Returns the page size for the horizontal scroll bar (ClientWidth). Returns the page size for the vertical scroll bar (ClientHeight). Returns the position for the thumb bar on the horizontal scroll bar, or 0 if the scroll bar is not visible. Returns the position for the thumb bar on the vertical scroll bar, or 0 if the scroll bar is not visible. Gets the effective selected state using the control Options and the grid draw state.

Called from the PrepareCanvas method when fixed cells are drawn, or when DefaultDrawing is enabled for the control.

Grid draw state values examined in the method. True when the state and Options values indicate a selected state. Gets the edit mask for the specified cell.

GetEditMask provides the mask posted in a grid message to an active cell Editor control. It occurs immediately before the grid message that posts the cell value to the editor control.

GetEditMask always returns an empty string ('') in TCustomGrid. It is overridden in descendent classes.

Edit mask for the specified cell. Column number for the cell. Row number for the cell. Gets the text displayed in the Editor for the specified cell.

GetEditText always returns an empty string ('') in TCustomGrid. It is overridden in descendent classes like TCustomDrawGrid and TCustomStringGrid to signal an OnGetEditText event handler.

GetEditText is called from the EditorDoSetValue method when TGridMessages are dispatched to the Editor to set the edit mask and value used in the control.

Text displayed in the cell editor. Column number for the editor text. Row number for the editor text. Gets the value for the FixedColor property. Value for the FixedColor property. Gets the column number for the first visible non-fixed column in the grid.

GetFirstVisibleColumn is an Integer function used to get the column number for the first visible non-fixed column in the grid. A visible column is one which starts after the fixed columns specified in FixedCols and has a non-zero width for the column in ColWidths.

The return value contains the column number (zero-based) for the column matching the criteria. If a non-fixed column with a non-zero width is not found, the return value is set to ColCount.

GetFirstVisibleColumn is called from the KeyDown method when handling Tab key navigation for the grid control.

Column number for the first visible column. Gets the row number for the first visible non-fixed row in the grid.

GetFirstVisibleRow is an Integer function used to get the row number for the first visible non-fixed row in the grid. A visible row is one which starts after the fixed rows specified in FixedRows and has a non-zero height for the row in RowHeights.

The return value contains the row number (zero-based) for the row matching the criteria. If a non-fixed row with a non-zero height is not found, the return value is set to RowCount.

GetFirstVisibleRow is called from the KeyDown method when handling Tab key navigation for the grid control.

Row number for the first visible row. Gets the column number for the last visible non-fixed column in the grid.

GetLastVisibleColumn is an Integer function used to get the column number for the last visible non-fixed column in the grid. A visible column is one which has a non-zero width for the column in ColWidths.

The return value contains the column number (zero-based) for the column matching the criteria. If a column with a non-zero width is not found, the return value contains -1.

GetLastVisibleColumn is called from the KeyDown method when handling Tab key navigation for the grid control.

Position for the last visible column in the grid. Gets the row number for the last visible non-fixed row in the grid.

GetLastVisibleRow is an Integer function used to get the row number for the last visible non-fixed row in the grid. A visible row is one which has a non-zero height for the row in RowHeights.

The return value contains the row number (zero-based) for the row matching the criteria. If a row with a non-zero height is not found, the return value contains -1.

GetLastVisibleRow is called from the KeyDown method when handling Tab key navigation for the grid control.

Row number for the last visible non-fixed row. Gets the value for the SelectedColor property. Value for the properly. Gets the prefix option for the title in the specified column number.

GetTitleShowPrefix determines whether the DT_NOPREFIX DrawText flag is included in the Canvas text style for the specified column. When GetTitleShowPrefix returns False, the DT_NOPREFIX flag in included in the text style.

GetTitleShowPrefix is called from the PrepareCanvas method when drawing a cell in the fixed rows for the grid.

TCustomControl.Canvas TTextStyle
True when the TGridColumn is configured to use prefixes. Column number examined in the method. Gets a TPoint instance with the top and left coordinates for the first visible, non-fixed row in the grid control.

GetPxTopLeft is used to implement scrolling operations in the WMHScroll and WMVScroll window message handlers.

TPoint instance with the coordinates for the row. Gets the truncated version of the hint for the cell at the specified position. Truncated text for the cell hint. Column number for the hint text. Row number for the hint text. Gets the ordinal position in Columns for the visible column specified in ColumnIndex.

GridColumnFromColumnIndex is an Integer function used to get the position in Columns for the visible column represented by ColumnIndex. It is necessary because a grid can include 0 or more fixed columns. This is a problem because: A) the fixed columns are both optional and variable, and B) the Columns collection uses ordinal values and never includes a column definition for fixed column.

ColumnIndex refers to the ordinal position for a visible column in the display area for the grid control. The return value is calculated as ColumnIndex + FirstGridColumn. In previous versions of the LCL, the value was derived using values from VisibleIndex and FixedCols.

The return value is -1 if the computed value is larger than ColCount-1.

GridColumnFromColumnIndex is used when a new value is assigned to the Index property in a TGridColumn instance. It is also used in the DialogChar method to locate and perform the OnClick handler for the column header where an accelerator key is found.

TCollectionItem.Index
Ordinal position in Columns for the visible column in ColumnIndex. Ordinal position for the visible column to locate in the Columns collection. Performs actions to apply a mouse wheel message to the grid control.

GridMouseWheel ensures that the Delta value for the mouse wheel event is correctly applied for horizontal scroll messages. These are the scroll messages which occurs when the Ctrl key is pressed. GridMouseWheel calls the MoveNextSelectable for both horizontal and vertical messages, but the value in Delta is used as the column argument when Ctrl is included in the Shift modifier. Otherwise, Delta is used as the Row argument.

GridMouseWheel is called from methods like: DoMouseWheelDown, DoMouseWheelUp, DoMouseWheelLeft, and DoMouseWheelRight.

Shift state modifier in effect for the action. Relative change in the current position for the action. Performs actions needed when a mouse click occurs in a fixed header for a grid column or row.

HeaderClick ensures that the value in SortOrder is toggled when Index contains the SortColumn defined for the grid control. SortOrder is set to soAscending when Index contains a column number other than SortColumn. SortColumn is updated in the method to use the value in Index as the active sort column.

HeaderClick calls the Sort method to sort all non-fixed rows in the grid control using the content from the column number in Index.

No actions are performed in the method when ColumnClickSorts is set to False.

IsColumn indicates whether the header click applies to a column or a row. When set to True, the mouse click occurred in a fixed header for the column number in Index. This parameter implies that similar handling is provided in the method for a header click on a fixed header in a row. No actions are performed for a header click on a row.

HeaderClick is overridden in descendent classes like TCustomDrawGrid to perform additional actions.

HeaderClick is called from methods like DialogChar and MouseUp.

True if the click occurred on a column header. False for a row header. Column (or row) number for the header click. Performs actions needed when a column or a row has been resized.

HeaderSized is used to perform actions needed when the header for a column or row has been resized in the grid control.

IsColumn indicates whether the sizing action applies to a column or a row. When set to True, the column header has been resized. When set to False, the row header was resized.

Index indicates the column or row number in the grid where the resizing action occurred.

HeaderSized has an empty implementation in TCustomGrid. It is overridden in descendent classes like TCustomDrawGrid to perform additional actions.

HeaderSized is called from methods like MouseUp (when column or row sizing is completed) and DblClick (when column sizing is enabled in the grid Options).

True if a column was resized, False if a Row was resized. Column or row number for the resize operation. Performs actions to resize a column or row to the specified size.

HeaderSizing has an empty implementation in TCustomGrid. It is overridden in descendent classes.

True when the resize action is for a column, or False for a row. Column or row index resized in the method. New size for the column or row. Cancels the current hint display and restores the saved hint for the grid control.

HideCellHintWindow is a method used to cancel the current hint display, and to restore the saved Hint for the grid control. HideCellHintWindow calls the CancelHint method in the Application singleton to discard the current hint window.

Performs actions needed to set the column count in the grid control.

Called when a new value is assigned to the ColCount property (SetColCount).

New column count for the control Indicates if the specified index position is valid for the columns in the grid.

Returns True when AIndex is a valid column index in the range 0..ColCount-1.

IsColumnIndexValid is used in several methods which access a column definition or data by its ordinal position in the grid control.

True when Index is in range for the column definitions in the grid. Index position examined in the method. Indicates if the specified index position is valid for the rows in the grid.

The return value is True when AIndex is in the range 0..RowCount-1.

True when Index is in range for the rows in the grid. Index position examined in the method. True when the column index is in the range FixedCols..ColCount-1. True when the column index is in the range FixedCols..ColCount-1. Column index position checked in the method. Indicates if the specified row is a valid, non-fixed row in the grid control. True when AIndex is a valid, non-fixed row in the grid control. Row number to examine in the method. Indicates if the cell at the specified position is a fixed column header.

Returns True when all of the following conditions are satisfied:

  • FixedRows contains a positive non-zero value
  • ARow contains zero (0) (first row in the grid)
  • ACol contains a value >= FirstGridColumn
True if the cell is a fixed column header. Column number for the cell. Row number for the cell. Gets the value for the indexed IsCellSelected property.

Compares the cell coordinates in ACol and ARow to the current range selection(s) in the grid control. The return value is True if the cell is in the current range selection for the control.

If RangeSelectMode is set to rsmMulti, all of the existing range selections are examined for the specified cell. The return is True when the cell is located in the array of rectangles used for multi-selections in the grid control.

Otherwise, the return value is set to False.

Boolean value for the indexed property. Column number for the cell examined in the method. Row number for the cell examined in the method. Indicates if all non-fixed cells in the specified row are empty. True when all non-fixed cells in the specified row contain empty strings (''). Row number for the cells examined in the method. Indicates if the specified mouse position is over a cell defined with a button column cell editor.

The return value is True when the mouse coordinates in X and Y are located over a cell which uses a button column cell editor. IsMouseOverCellButton temporarily disables AllowOutBoundEvents while the return value is determined.

IsMouseOverCellButton is used in the implementation of the MouseDown method to determine if the cell needs to be drawn in a pushed state.

True when the mouse coordinates in X and Y are located over a cell which uses a button column cell editor. Horizontal screen coordinate for the mouse pointer. Vertical screen coordinate for the mouse pointer. Handles key down events for the grid control.

KeyDown is overridden in TCustomGrid to ensure that keys handled by the grid or its Editor are properly applied to the control. KeyDown calls the inherited method on entry to signal the OnKeyDown event handler (when assigned) or any other key handlers for the control.

CanGridAcceptKey is called to determine whether Key and Shift are ignored in the control.

KeyDown handles the following key codes:

VK_TAB
Performs cell navigation when goTabs in included in the Options for the grid. Ensures that goAutoAddRowsSkipContentCheck in Options is supported. When TabAdvance is set to aaNone, the key and modifier are forwarded to the Editor control.
VK_LEFT
Moves to the previous cell when the Editor is not active.
VK_RIGHT
Moves to the next cell when the Editor is not active.
VK_UP
Moves the selection to the previous visible row.
VK_DOWN
Moves the selection to the next visible row.
VK_PRIOR (Page Up)
Moves upward in the grid by the number of visible rows.
VK_NEXT (Page Down)
Moves downward in the grid by the number of visible rows.
VK_HOME
Moves to the first non-fixed row in the grid. The current column is used. When goRelaxedRowSelect is included in Options, the selection is moved to the first non-fixed column in the current row.
VK_END
Moves to the last non-fixed row in the grid. The current column is used. When goRelaxedRowSelect is included in Options, the selection is moved to the last non-fixed column in the current row.
VK_APPS (Menu Pop-up on PC keyboards)
Displays the Pop-up menu for the cell Editor when editing is allowed in the column.
VK_F2
Selects and displays the cell Editor when editing is allowed in the column.
VK_BACK (Backspace)
Fowards the Backspace character (^H) to the cell Editor when editing is allowed in the column.
VK_C
Performs a copy to clipboard operation when ssCtrl or ssMeta is in the Shift modifier.
VK_V
Performs a paste from clipboard operation when ssCtrl or ssMeta is in the Shift modifier.
VK_X
Performs a cut to clipboard operation when ssShift is in the Shift modifier.
VK_DELETE
Clears the value in the cell Editor and redraws the current cell when editing is allowed for the column.
VK_ESCAPE
Resets the value in the cell Editor, and hides the Editor control when it is both assigned and visible.

When Key is handled in the method, it is set to 0 (zero).

Called from EditorKeyDown when key down events are enabled in the EditorOptions for the control.

TWinControl.KeyDown
Key code examined in the method. Shift / Ctrl / Alt modifier for the key code. Applies the specified key press character to the control.

KeyPress is a method used to apply the character in Key to the grid control. KeyPress is overridden to ensure that a key which originated from the grid control is applied properly to the cell Editor (when needed). It calls the inherited method on entry.

The following key press values in Key are handled in the method:

Enter (#13)
Gets and displays the cell Editor when EditMode is False and the column allows editing.
Backspace (^H) and characters in the range #32..#255 (data)
Applies the key press to the Editor.

When Key is handled in the method, it is set to #0 prior to exit.

TWinControl.KeyPress
Key press character examined in the method. Loads values for the grid control from the specified XML configuration file.

LoadContent is a method used to load content from the XML configuration file specified in cfg into the grid control.

Design-time settings for the grid control are loaded from the XML file when soDesign is included in the SaveOptions property and the XML file includes the corresponding values.

Property values loaded in the method include:

  • Color
  • ColCount
  • RowCount
  • FixedCols
  • FixedRows
  • DefaultRowHeight
  • DefaultColWidth
  • ColWidths
  • RowHeights
  • Columns

The LoadGridOptions method is called to load values for the Options and Options2 properties.

The columns and rows visible in the grid control are loaded and restored when they are included in the XML file. This includes the range selection rectangle in RangeSelect when enabled in the Options for the control.

In TCustomGrid, LoadContent does not load the cell values for the control. That process is implemented in descendent classes which handle the data type(s) supported in the implementation.
Configuration file with values loaded in the method. LCL Grid version number for the values processed in the method. Loads design-time values for the Options in a grid from an XML configuration file.

LoadGridOptions is method used to load value for the Options and Options2 properties from the XML configuration file specified in cfg.

Design-time settings for the grid control are loaded from the XML file when soDesign is included in the SaveOptions property and the XML file includes the corresponding values. LoadGridOptions reads the enumeration values for both properties from the XML configuration file and stores the set types to the Options and Options2 properties.

LoadGridOptions is called during execution of the LoadContent method.

XML configuration file instance examined in the method. LCL version for the grid option data. Performs actions when the component has been loaded using LCL component streaming.

Calls the inherited method on entry, and calls VisualChange to resize columns and redraw the grid control.

TWinControl.Loaded
Locks the Editor so that it cannot accept input or changes.

LockEditor increments the value for the internal lock counter used to get the return value for the EditorLocked method. LockEditor is called from the MouseDown method when a mouse click occurs in the cell data for the grid control, and prevents a cell Editor from being displayed until the mouse event is handled. It is also called from the EditorHide method to prevent access to an Editor until the current one is hidden.

Indicates if the specified mouse button is a mouse down event used in the control.

Called from the MouseDown method to ignore Right mouse clicks in the grid control at design-time. This allows the mouse event to be handled as a context menu on the form design surface.

True if the specified mouse button is valid for the grid control. TMouseButton value examined in the method. Handles mouse down events for the grid control.

MouseDown is overridden in TCustomGrid to ensure that cached grid information in GCache is updated for mouse down events, and both GridState and GridFlags are updated for the control.

MouseDown calls the inherited method to handle focus changes for the control and drag operations. The OnMouseDown event handler is signalled (when assigned) by the ancestor.

No additional actions are performed in the method at design-time, when the mouse Button is not allowed in the grid control, or when the control cannot receive focus.

MouseDown ensures that the grid control is focused when visible and enabled, and does not contain csNoFocus in the ControlStyle flags. MouseDown updates GCache with the coordinates for the mouse down event. The grid "hot" zone in the cached information determines the value assigned to GridState, GridFlags, CursorState and the actions performed for the mouse event.

gzFixedCells

Sets GridState to gsColSizing when both goColSizing and goFixedColSizing have been included in the Options and the cursor state is gcsColWidthChanging.

Otherwise, GridState is set to gsHeaderClicking. The cell is drawn in a "pushed" state when goHeaderPushedLook is included in Options and the grid zone is in HeaderPushZones.

gzFixedCols

GridState is set to gsColSizing when goColSizing has been included in the Options and the cursor state is gcsColWidthChanging.

Otherwise, GridState is set to gsColMoving. The cell is drawn in a "pushed" state when goHeaderPushedLook is included in Options and the grid zone is in HeaderPushZones.

gzFixedRows

GridState is set to gsRowMoving when goRowSizing is included in Options and CursorState is gcsRowHeightChanging.

Otherwise, GridState is set to gsRowMoving. The cell is drawn using the "pushed" state when goHeaderPushedLook is included in Options and the grid zone is in HeaderPushZones.

gzNormal

When the mouse down event is over a button-style cell, it is drawn in the "pushed" state. No additional actions are needed for the event.

Other cells use the values in Options and CursorState to determine whether the mouse event is for column sizing, selection, or enabling/disabling the cell editor. GridState is updated to the corresponding value.

TControl.MouseDown
Mouse button for the event. Shift state for the event. Horizontal coordinate for the mouse event. Vertical coordinate for the mouse event. Applies a change in the mouse pointer position to the grid control.

MouseMove is an overridden method in TCustomGrid. It calls the inherited method on entry to update the DragManager when it is active, and to signal the OnMouseMove event handler (when assigned). No additional actions are performed in the method if a drag operation is already active in the DragManager.

If the mouse coordinates are located in the fixed headers for the control, hot tracking and cell down / pushed drawing are applied to the grid control when enabled in Options.

Cell selections are handled for the mouse movement depending on grid state values and Options set for the control. No additional actions are performed in the method when gsHeaderClicking or gsButtonColumnClicking are in the grid state for the control. Performs the following for a corresponding mouse movement:

Extend an active selection in the control when needed.
Calls MoveExtend when the mouse pointer is not in the current selection, not in a fixed header area for the control, and editing is not active or allowed. Occurs when gsSelecting is in the grid state values for the control.
Move the column under the mouse pointer.
Occurs when goColMoving is in Options.
Resize the column under the mouse pointer.
Occurs when goColSizing is in Options.
Resize the row under the mouse pointer.
Occurs when goRowSizing is in Options.

MouseMove sets the Hint displayed for the cell under the mouse pointer when ShowHint is enabled. Values in Hint, CellHintPriority, Options, and the OnGetCellHint event handler are used for the purpose. If the mouse pointer is not over a cell, the Hint for the application is reset to a previous hint or an empty string ('') when saved hint text is not available.

Called from WMMouseMove when a LM_MOUSEMOVE window message is handled for the grid control.

TControl.MouseMove TControl.WMMouseMove
Ctrl, Alt, or Shift modifier for the mouse event. Horizontal coordinate for the mouse pointer. Vertical coordinate for the mouse pointer. Handles a mouse up event for the grid control.

MouseUp is an overridden method in TCustomGrid used to perform actions needed when a mouse up event has been received for the grid control. It calls the inherited method on entry to signal the OnMouseUp event handler (when assigned). MouseUp performs additional actions based on the grid zone where the mouse up event occurred and the current grid state flags for the control.

For example:

Mouse event on a fixed header for the grid.
Calls HeaderClick for the column header under the mouse pointer. Changes the sort order in the column when enabled. Occurs when gsHeaderClicking is in the grid state flags.
Mouse event on a column button in the grid header.
Calls DoEditButton to signal the OnEditButtonClick or OnButtonClick event handlers (when assigned). Occurs when gsButtonColumnClicking is in the grid state flags.
Mouse event on a non-fixed cell in the grid control.
Selects and displays an editor for the cell, and calls the CellClick method to apply the mouse event to the cell. If a selection is already active in the control, it is extended to include the range of cells ending at the mouse pointer. Occurs when gsNormal or gsSelecting is in the grid state flags.
The mouse event occurs when dragging a column header.
Moves the dragged column to the column position under the mouse pointer. Calls HeaderClick to refresh the sort order for cells in the column. Occurs when gsColMoving is in the grid state flags.
The mouse event occurs when dragging a row header.
Moves the dragged row to the row position under the mouse pointer. Calls HeaderClick to refresh the sort order for cells in the row. Occurs when gsRowMoving is in the grid state flags.
The mouse event occurs when resizing a column header.
Calls ResizeColumn to apply the new column size, and calls the HeaderSized method for the resized column number. Occurs when gsColSizing is in the grid state flags.
The mouse event occurs when resizing a row header.
Calls ResizeRow to apply the new row size, and calls the HeaderSized method for the resized row number. Occurs when gsRowSizing is in the grid state flags.

Values in GridFlags are updated to remove flag values for the handled actions, and the grid state is set to gsNormal prior to exit.

MouseUp is called when window messages are handled in the WMLButtonUp, WMRButtonUp, and WMXButtonUp methods in the ancestor class.

TControl.MouseUp TControl.OnMouseUp TControl.WMLButtonUp TControl.WMRButtonUp TControl.WMXButtonUp
Mouse button for the event notification. Ctrl, Alt, or Shift modifier for the mouse event. Horizontal coordinate for the mouse pointer. Vertical coordinate for the mouse pointer. Moves the selected cell or extends a selection using the specified column and row values.

Calls TryMoveSelection to perform the selection change using the specified arguments. No actions are performed in the method when:

  • FixedGrid is True. All cells are fixed and cannot be selected.
  • DCol and DRow are not valid for the Col, Row, ColCount or RowCount for the grid control.
True if the selection was moved or extended in the method. True if the selection is extended by the relative number of columns and rows. False to move the selection to the specified cell coordinates. Column number for the selection, or the delta when a selection is extended. Row number for the selection, or the delta when a selection is extended. True if the cell in DCol and DRow must be fully visible after the selection change. Moves to the next cell in the auto-advance sequence.

MoveNextAuto calls the GetDeltaMoveNext method to determine the column and row number for the next cell in the auto-advance sequence. It also sets the return value for the method. When it returns True, the MoveNextSelectable method is called to move to the new cell position in the direction indicated by Inverse.

MoveNextAuto is called from the EditorKeyPress method when the Enter or Shift+Enter key press is handled for the editor control on the grid.

True if a column and row number were successfully determined for the movement. True to move to the previous cell in the auto-advance sequence. False (the default value) to move forward in the sequence. Moves to the next selectable cell in the specified direction.

MoveNextSelectable is a Boolean function used to move either or extend the selection in the grid control by a specified number of selectable columns and rows.

Relative indicates whether the column and row arguments are relative to the current Col and Row (or current cell), or represent an absolute cell address.

When Relative is set to True, DCol and DRow can have positive or negative values which indicate the direction in which the selection is moved or extended. A positive value in DCol indicates the selection moves to the right. A negative moves the selection to the left. A positive value in DRow moves the selection towards the bottom of the grid. A negative value moves the selection towards the top of the grid.

Applications do not normally call MoveNextSelectable; it is used in the implementation of methods like:

  • KeyDown
  • MoveNextAuto
  • CheckPosition
  • GridMouseWheel

It is also called when a new value is assigned to the FixedCols or FixedRows property.

True if the selection was successfully moved or extended in the method. True if the selection is extended in the direction indicated by DCol and DRow. False if the selection is moved to the destination cell. Destination column for the selection. Destination row for the selection. Signals the OnSelection event handler for a new mouse selection.

MoveSelection signals the OnSelection event handler (when assigned) using the values in Col and Row as arguments.

Use The OnBeforeSelection, OnSelection, and OnAfterSelection event handlers to perform actions needed before, during, or after a range is selected on the grid control.

Use OnSelectCell to determine whether a specific column and row number can actually be selected.

Called from the MouseDown method when a mouse click in the non-fixed area for the grid is detected. It is also called from MoveExtend when range selection (goRangeSelect) is enabled in the Options for the control.

Performs actions needed when the specified component is added to or removed from the control.

Notification is an overridden method in TCustomGrid. It calls the inherited method on entry to handle notifications in ancestor classes and their child components. It ensures that the reference in TitleImageList is set Nil when the component is removed from the control.

TControl.Notification TComponent
Component for the notification. Operation performed for the specified component. Moves to a column or row located at the specified offset. Index and Rest arguments were changed to output parameters in LCL version 2.1 (revision 65087). True if a column and row number was identified for the specified offset. True if the offset is for a column, False for a row. True for a physical offset, False for a logical offset. Offset in pixels for the column or row. Index position for the column or row in the specified offset. Remaining pixels stating at the value in Index. Draws the edges, borders, and rows in the grid control.

Paint is an overridden method in TCustomGrid used to update and draw the grid control.

Values in GridFlags and GCache are examined to determine if a visual change to the columns or the client area for the control is in progress. For either condition, the ResetSizes method is called to handle the visual change(s) and the flag values are removed from GridFlags.

Paint calls the inherited method to signal the OnPaint event handler in the ancestor class.

If there are no other active updates for the control, methods are called to draw the edges and all visible rows in the control. If a column move operation is in effect, the Canvas is updated to display a drag cursor with the color defined in the grid. Borders for the control are drawn prior to exiting from the method.

TCustomControl.Paint
Signals the OnPickListSelect event handler when a selection is made in a picklist.

Called from the Select method when the text for the cell value is stored in a cell using a picklist-style Editor.

Object for the event notification. Prepares the canvas for drawing the cell at the specified location.

PrepareCanvas ensures that the Canvas for the control is properly configured to draw the cell at ACol and ARow using the drawing state specified in AState. Flags in AState and the values from the Options, Enabled, DefaultDrawing and EditorMode properties determine the Pen, Brush, Font, and TextStyle settings used in the control Canvas.

PrepareCanvas is called from ShowCellHintWIndow when truncated cell hints are enabled in the Options for the grid. It is also called from DrawCell before drawing the filled rectangle and grid lines for the cell.

Column number for the cell. Row number for the cell. Drawing state applied to the canvas for the specified cell. Prepares the control to display hints for a cell.

PrepareCellHints has an empty implementation in TCustomGrid, and may be overridden or re-implemented in descendent classes (like TCustomDBGrid, TDBGrid).

PrepareCellHints is called from the ShowCellHintWIndow method.

TCustomDBGrid.PrepareCellHints
Column number for the cell. Row number for the cell. Restores the default width for columns in the grid.

ResetDefaultColWidths updates an internal member with the list of column widths currently in use for the grid. The width for each column is set to -1 to indicate that an explicit value has not been assigned for the column width.

ResetDefaultColWidths calls the VisualChange method after resetting the column widths to their default values. No actions are performed in the method when AutoFillColumns contains True.

Resets the value in the cell Editor, and optionally re-displays and selects it content.

ResetEditor is a procedure used to reset the value in the cell Editor to the stored content for the current cell in the grid control.

ResetEditor calls EditorGetValue to retrieve the value for the current cell and to perform validation using the OnValidateEntry event handler (when assigned). If the column allows editing and goAlwaysShowEditor has been included in the Options for the grid, the EditorShow method is called to re-display the cell Editor and re-select all of the cell content.

ResetEditor is called from the DoExit method when the grid control receives the CM_EXIT control message.

Resets the member used to track the last row or column movement. Resets cached column (Top/Left) and row offsets. True if column or row offsets were updated in the method. True if the column offset is checked and updated, or False to ignore the cached offset. True if the row offset is checked and updated, or False to ignore the cached offset. Resets the internal column sizes.

No actions are performed in the method when the internal list of column sizes has not been allocated, during component streaming, or when the handle has not been allocated for the grid control.

Calls UpdateCachedSizes to recalculate the cached grid information in GCache. Calls CacheVisibleGrid to cache the current visible grid (excluding fixed cells).

Called from the Paint method when the client width or height has changed for the control.

Resizes the specified column number to the given width.

ResizeColumn is a method used to set the width for the column number specified in ACol to to the value in AWidth.

ResizeColumn ensures that the value in AWidth is at least 0 (zero). A negative column size is invalid. The value in AWidth is stored to the ColWidths property at the index position in ACol.

Use ResizeRow or RowHeights to change the height for a specific row in the grid control.

Column number resized in the method. New width for the column. Resizes the specified row number to the given height. Row number resized in the method. New height for the row. Performs actions needed when the values in RowHeights have been changed.

RowHeightsChanged has an empty implementation in the current version of the LCL. It is called when a new value is assigned to the RowHeights property and occurs after the cache, scroll bars, and cell editor position have been updated for the control.

Saves design-time configuration, column and row settings, and data to the specified XML configuration file.

Use LoadContent to load values saved in SaveContent method.

Needs to be updated using LoadContent as a template.
TXMLConfig instance where the content is stored. Saves grid options to the specified XML configuration file.

Stores TGridOption and TGridOption2 enumeration values found in the Options and Options2 properties to the XML configuration file specified in cfg. Used in the implementation of the SaveContent method.

Use LoadContent to load option settings into the current grid class instance.

XML configuration file where values are stored. Sets range information for the specified scroll bar.

Which contains an Integer value which indicates the scroll bar updated in the method. It corresponds to the SB_Horz, or SB_Vert values defined in the lcltype.pp unit. ARange, APage, and APos contain the values applied to the corresponding scroll bar.

ScrollBarRange allocates and initializes the TScrollInfo structure passed as an argument to the SetScrollInfo routine in the LCL interface. The value in the APos argument is translated for a horizontal scroll bar to be relative to ARange when right-to-left reading is used in the control.

ScrollBarRange is called from the UpdateHorzScrollBar and UpdateVertScrollbar methods.

Integer constant which identifies the scroll bar updated in the method. Maximum value for the scroll bar range. Specifies the page size for the proportionally-sized thumb bar. Current position in the scroll bar range. Sets the position for the specified scroll bar to the given value.

ScrollBarPosition is a method used to set position for the scroll bar specified in Which to the new Value.

Which contains either SB_Horz or SB_Vert, and identifies the scroll bar affected in the method.

Value contains the new position for the scroll bar.

ScrollBarPosition uses the SetScrollInfo routine to update the scroll bar position. It allocates the TScrollInfo structure and stores Value as the scroll bar position in the structure.

ScrollBarPosition calls ScrollBarIsVisible to determine if the scroll bar in Which is visible. The visibility is used when calling SetScrollInfo.

No actions are performed in the method if the Handle has not been allocated for the grid control.

Scroll bar updated in the method. New position for the scroll bar. Returns True if the specified scroll bar is visible. True if the specified scroll bar is visible. Identifies the scroll bar examined in the method (SB_Horz, SB_Vert). Updates the page size for the specified scroll bar.

Allocates and populates a TScrollInfo structure used to update the scroll information for the specified scroll bar(s). Calls the SetScrollInfo routine in the LCL interface to apply to the scroll information with the new page size.

No actions are performed in the method if the Handle has not been allocated for the grid control.

Which is an Integer argument that specifies the scroll bar(s) affected in the method, and can include the following constant values:

SB_HORZ
Horizontal scroll bar
SB_VERT
Vertical scroll bar
SB_BOTH
Both horizontal and vertical scroll bars
ScrollBarPage is not used in the current LCL implementation.
Identifies the scroll bar affected in the method. New value for the page size used on the proportional thumb bar. Displays or hides scroll bar(s) for the grid control.

ScrollBarShow is a procedure used to control the visibility of the scroll bars for the grid.

Which is an Integer argument that specifies the scroll bar(s) affected in the method, and can include the following constant values:

SB_HORZ
Horizontal scroll bar
SB_VERT
Vertical scroll bar
SB_BOTH
Both horizontal and vertical scroll bars

aValue is a Boolean argument that indicates if the specified scroll bar(s) are visible or hidden. When aValue contains True, the corresponding scroll bar(s) are displayed. Otherwise, they are hidden.

No actions are performed in the method if a handle has not been allocated for the grid (HandleAllocated returns False). ScrollBarShow ensures that gfUpdatingScrollbar is included in the grid flags prior to calling the ShowScrollBar routine in the LCL interface. The flag value is removed immediately after updating the scroll bar display. Internal members used to track scroll bar visibility are set to the state requested in AValue.

ScrollBarShow is called from the UpdateHorzScrollBar and UpdateVertScrollbar methods, as well as the private UpdateSBVisibility method.

TWinControl.HandleAllocated ShowScrollBar
Scrollbar(s) affected in the method. True indicates the scroll bar(s) are visible. Indicates whether an automatic scroll bar of the given type is used on the grid control.

Translates the value in Which to the automatic equivalent (ssAutoVertical, ssAutoHorizontal, ssAutoBoth), and checks the ScrollBars property for the value(s).

TScrollStyle
True if an automatic scroll bar is used for the specified type. Scrollbar type (ssHorizontal or ssVertical) checked in the method. Scrolls the non-fixed area for the control by the specified delta values.

Calls ScrollWindowEx to perform the scrolling operation for the non-fixed client area in the control. No scrolling is performed when both DeltaX and DeltaY contain 0 (zero).

Updates the visible grid area in the cached information for the control, and recalculates the scroll bar ranges.

TWinControl.ScrollBy
Scroll amount in the horizontal direction. A negative value scrolls to the left, and a positive value scrolls to the right. Scroll amount in the vertical direction. A negative value scrolls toward the top, and a positive value scrolls toward the bottom. Gets the cell editor for the current cell, and sets its PopupMenu.

Calls GetDefaultEditor to retrieve the default Editor used for the column where the current cell is located (Col).

In situations where the current cell is not selectable in the grid, when FixedGrid is True as an example, the default cell Editor is set to Nil. The OnSelectEditor event handler is signalled (when assigned) to determine if a cell Editor (or none) is available for the editable column.

If an Editor has been assigned, but does not have a PopupMenu, the PopupMenu for the grid control is used in the Editor.

SelectEditor is called when goEditing is included in the Options for the grid control. It is also called when Options is configured to always display cell editors (goAlwaysShowEditor), and an editable non-fixed cell is selected in the MouseDown method. Similarly, it is called from MouseUp when a mouse click selects a new editable cell in the grid control.

Determines whether the specified cell can be selected in the grid control.

SelectCell is a Boolean function used to determine whether the cell specified in ACol and ARow can be selected in the grid control. The return value is True when both ColWidths and RowHeights have positive non-zero values for the column and row numbers where the cell is located.

SelectCell is used in the implementation of methods like TryMoveSelection, CheckPosition, SelectEditor, and GetDeltaMoveNext. It is overridden in TCustomDrawGrid to signal the OnSelectCell event handler (when assigned).

Component developers may use the SelectCell method to react to focus changes. The Result is True if the cell can be selected.

True when the cell can be selected in the grid control. Column number for the cell. Row number for the cell. Sets the Canvas font to the specified value.

SetCanvasFont is used to assign the TFont instance in AFont to the Canvas for the grid control.

Different fonts can be used to render the title in fixed headers and the data in the cells. The font used is determined (and assigned) when the PrepareCanvas method configures the Canvas to draw cells in the grid. SetCanvasFont ensures that the new font is stored in an internal member when the font is assigned to the Canvas.

Font applied to the canvas for the grid. Sets the value in the ColCount property. New value for the property. Sets the value in the Color property. TControl.Color New value for the property. Makes the specified column and row a selected cell in the grid control.

ACol and ARow contain the coordinates for the cell affected in the method.

WithEvents indicates whether the specified cell is added to the Selections for the grid control, or if it becomes the selected cell.

When WithEvents is set to True, MoveExtend is called to add the cell to the current range. This also causes the Click method to be called to signal the OnClick event handler (when assigned).

When WithEvents is set to False, argument values are assigned to the Col and Row properties in the grid control. UpdateSelectionRange is called to update the cell rectangle for the cell or row selection.

Column number for the selected cell. Row number for the selected cell. True if the OnClick event handler is signalled for the change to the selected range. Changes the cursor shape in the grid to the specified value.

SetCursor is an overridden method in TCustomGrid. SetCursor calls the inherited method to perform the CM_CURSORCHANGED message for the control, and calls ChangeCursor to save the previous Cursor and apply the shape in AShape to the Cursor property.

Cursor shape used for the mouse pointer in the grid. Sets the value used in the cell Editor to the specified text.

Sets the the text displayed in the Editor for the cell at the position specified in ACol and ARow to the given value.

SetEditText has an empty implementation in TCustomGrid. It is overridden in TCustomDrawGrid to signal the OnSetEditText event handler (when assigned).

SetEditText is used in KeyDown when the Escape key (VK_ESCAPE) is not handled by the grid control. It is called from the EditorGetValue method when a visible cell Editor is updated. It is called from EditorTextChanged method when the value in a cell Editor has been altered using the Change or Select methods in the editor control.

Column number for the editor value. Row number for the editor value. New value for the cell Editor. Sets the value for the BorderStyle property. New value for the BorderStyle property. Sets the value for the FixedColor property. New value for the FixedColor property. Sets the value for the FixedCols property. New value for the FixedCols property. Sets the value for the FixedRows property. New value for the FixedRows property. Sets the width for the specified column number in the internal list. Column number for the specified width. Width in pixels for the specified column. Sets the value for the SelectedColor property. New value for the SelectedColor property. Sets the value for the FadeUnfocusedSelection property.

Changing the value for the property causes the control to be redrawn.

New value for the FadeUnfocusedSelection property. Gets and displays the cell hint(s) for the current cell in the grid.

ShowCellHintWindow is a procedure used to gets the value(s) and display cell hint(s) for the cell located at the screen position in APoint. Values in the Options and the CellHintPriority properties determine the text available for use as cell hints.

GetCellHintText and GetTruncCellHintText are called to get the corresponding hint text for the options and hint priority. AddToHint is called to apply the derived text to the values displayed in the control using its Hint property. Application.ActivateHint is called to display the hint window.

No actions are performed in the method when ShowHints contains False, when the mouse pointer is not positioned over a grid cell, when EditorMode is True, or at design-time.

Screen coordinates for the mouse pointer. Performs actions needed when the number of columns or rows has been changed.

SizeChanged has an empty implementation in TCustomGrid. It is overridden in TCustomDrawGrid to perform a notification when the column and/or row count has been changed for the control.

Previous number of columns. Previous number of rows. Sorts rows or columns in the grid.

Sort is a method used to sort items in the grid. When ColSorting is True, it sorts the items in a column. Otherwise, it sorts values in a row. The three index values specify the items to be sorted.

True if a column is affected in the method. False if a row is affected. Column or row number for the values sorted in the method. Position for the first value sorted in the method. Position for the last value sorted in the method. Starts an operation to render a cell in its "pushed" state.

StartPushCell updates the GridState property to the value gsButtonColumnClicking, and calls the DoPushCell method to cache and redraw the clicked cell.

StartPushCell is called from the MouseDown method when a mouse click has occurred over a cell using a button-style Editor in the non-fixed area for the grid control.

Signals the OnTopLeftChanged event handler (when assigned) at run-time.

TopLeftChanged occurs when the origin for the scrollable area in the control has been changed.

TopLeftChanged is called from methods like TrySmoothScrollBy, UpdateCachedSizes, and FixPosition. It is also called when the AutoFillColumns property is set to True.

Tries to move the cell selection by or to the specified column and row values.

TryMoveSelection is a Boolean function used to select the cell represented in the DCol and DRow arguments. These values can be either an absolute cell address or relative offsets from the current cell in Col and Row.

When Relative is True, the arguments can contain positive or negative values. Positive values move the selection to the right (for DCol) or towards the bottom of the grid (for DRow) starting at the cell in Col and Row. Negative values cause the selection to move in the opposite directions for each argument.

When Relative is False,the arguments in DCol and DRow are absolute cell coordinates and should contain only positive values.

TryMoveSelection calls SelectCell to select the cell at the specified column and row.

The return value is True if the specified cell was selected in the method. It is False if DCol or DRow do not represent a valid cell in the grid control. No actions are performed in the method when FixedGrid returns True, and the return value is set to False.

TryMoveSelection is called from the MoveExtend method and occurs before the OnBeforeSelection, OnSelection, and OnAfterSelection event handlers are signalled.

True on success. True the column and row numbers are relative offsets from the current cell. Column offset or number for the selection. Row offset or number for the selection. Decrements the lock count for the cell Editor following a call to LockEditor.

LockEditor and UnlockEditor are used to surround operations where a cell Editor is hidden or the focus is changed as a result of keyboard navigation or a mouse click event.

UnlockEditor is called from methods like MouseDown and EditorHide.

Re-implemented in descendent classes.

UnprepareCellHints has an empty implementation in TCustomGrid, but it overridden in descendent classes (like TCustomDBGrid / TDBGrid).

UnprepareCellHints is called from the ShowCellHintWindow method.

Updates the horizontal scroll bar to use the specified range, page, and position.

UpdateHorzScrollBar calls ScrollBarShow to updated the scroll bar visibility when it differs from the value in aVisible. The ScrollBarRange method is called to apply the values in ARange, APage, and APos to the horizontal scroll bar for the control. No actions are performed if the visibility has not been changed and the scroll bar is not visible.

UpdateHorzScrollBar is called from the CalcScrollbarsRange method when the visible area in the grid is scrolled.

True if the scroll bar is visible. Maximum position for the scroll bar. Page size for a thumb tab in the scroll bar. Position for the scroll bar. Updates the selection range when the current selection in the grid has changed.

UpdateSelectionRange is a method used to update the Selection property with the cell coordinates for the current cell or row in the grid control. UpdateSelectionRange creates a new TRect instance with the cell coordinates representing the current selection in the grid.

UpdateSelectionRange uses values in Options to determine whether the rectangle represents a single cell or the current Row. When goRowSelect has been included in Options, the rectangle contains the non-fixed column and last column numbers in the current Row. Otherwise, the rectangle uses the value in Col and Row to represent both the start and end cells for the Selection.

UpdateSelectionRange is called from the ClearSelections and FixPosition methods.

Updates the vertical scroll bar to use the specified visibility, range, and page values.

UpdateVertScrollbar calls ScrollBarShow to updated the scroll bar visibility when it differs from the value in aVisible. The ScrollBarRange method is called to apply the values in ARange, APage, and APos to the vertical scroll bar for the control. No actions are performed if the visibility has not been changed and the scroll bar is not visible.

UpdateVertScrollbar is called from the CalcScrollbarsRange method when the visible area in the grid is scrolled.

True if the scroll bar should be visible. Maximum position for the scroll bar. Page size for a thumb tab in the scroll bar. Position for the scroll bar. Updates the border style used for the control.

UpdateBorderStyle is a method used to apply a BorderStyle for the control that is valid for the value in the Flat property. When Flat is set to False, the value in BorderStyle is used. When Flat is True, the value bsNone is always used as the BorderStyle for the control.

UpdateBorderStyle calls the inherited SetBorderStyle method to apply the derived value to the BorderStyle property.

UpdateBorderStyle calls VisualChange to refresh the control after the change to the property, and validates the Top and Left for the visual area in the grid. These actions are not performed if the Handle has not been allocated for the control, or during LCL component streaming.

UpdateBorderStyle is called when the value for the Flat property has been changed.

Validates the value for the specified cell.

ValidateEntry is a Boolean function used to a validate the value for the cell at the specified Col and Row position.

ValidateEntry signals the OnValidateEntry event handler (when assigned) to perform validation for the cell. The return value is True when OnValidateEntry completes successfully, or when the event handler has not been assigned.

True when validation completes successfully. Column number for the operation. Row number for the operation. Value on entry to the method. Value on exit from the method. Updates the grid after changes to the visual properties in the control.

VisualChange is a procedure used to update the grid when visual aspects of the control have been changed. VisualChange calls UpdateSizes to refresh the size of cells in the grid, and calls Invalidate to cause the control to be redrawn.

No actions are performed in the method when BeginUpdate has already been called to buffer updates to the grid. VisualChange will resume updates when EndUpdate has been called to disable update buffering.

Handles a WM_SIZE window message for the control.

Ignores the message when updating scroll bars (gfUpdatingScrollbar in GridFlags). Otherwise, the inherited method is called to handle the window size message.

TWinControl.WMSize
Message handled in the method. Handles the system message for horizontal scrolling. Message applied in the method. Handles the system message for vertical scrolling. Message applied in the method. Handles the LM_KILLFOCUS message for the control. TWinControl.WMKillFocus Message handled in the method. Handles the LM_KILLFOCUS message for the control. TWinControl.WMSetFocus Message handled in the method. Extends the message processing loop for the grid control.

WndProc is an overridden method in TCustomGrid. It extends the ancestor method to provide design-time support for the grid control. LM_HSCROLL and LM_VSCROLL messages are not processed at design-time.

For the Windows platform, message processing is halted when a LM_SIZE message is being processed. Windows sends WM_SIZE when showing or hiding scroll bars, and can occur during the DoOnChangeBounds method.

WndProc calls the inherited method to handle focus, mouse, key, and state change messages.

WndProc ensures that a TGridScroller instance allocated for the class is freed after a scroll message has been handled and the grid state has been updated.

TWinControl.WndProc
Message examined in the method. Allows a mouse click on unused space in the control, and moves the cursor to the nearest valid cell.

Normally, when a user clicks on a point over the empty space after cells (for example if grid has three rows but user clicks on imaginary fourth row) the current focused cell will move to the nearest cell to clicked point. We call this an outbound event.

The default value or the property is True, as this has been the grid's behavior since the beginning.

This was added to mimic Delphi behavior where outbound events are not available; to enable Delphi compatibility, set AllowOutboundEvents to False.

Color used for the background in alternate rows in the grid.

AlternateColor is a TColor property with the background color used for alternate rows on the grid control. Color is used as the background color for even-numbered rows. Having alternate rows in different colors can make the grid easier to read.

AlternateColor is initially set to the value for Color property in the constructor. Setting a new value for the property causes the grid control to be redrawn. AlternateColor is updated when a new value is assigned to the Color property; it assumes the old value in Color.

Color and AlternateColor are used in the PrepareCanvas method to set the Canvas brush color for cells which are not selected in a given row.

TColor TControl.Color
Direction used when automatically moving the selection to the next selectable cell.

AutoAdvance is a TAutoAdvance property which indicates the direction of movement applied when the Enter key is pressed to finish editing in an active cell Editor.

The default value for the property is aaRight, and indicates the cell selection advances to the right until it reaches the last column in the grid control. Use aaNone to disable the auto-advance feature.

For more information about acceptable values and their usage, please refer to TAutoAdvance.

AutoAdvance is used in methods like MoveNextAuto and CheckPosition.

Use TabAdvance to control the direction of movement used when the Tab key is pressed.

Indicates if edit mode is automatically entered when a cell is selected.

AutoEdit is a Boolean property which indicates if edit mode is automatically entered when a cell is selected in the grid control. The default value for the property is True.

When AutoEdit is set to True, the cell Editor is automatically displayed when a non-fixed cell is entered using keyboard navigation or a mouse click. When AutoEdit is set to False, the cell Editor is not displayed until toggled. Use the F2 or Enter key to activate a cell Editor. Use a second mouse click in the active cell to display the cell Editor.

AutoEdit does not allow a cell to be edited if the column definition in the Columns collection is defined as ReadOnly.

Use the Options property to enable or disable editing in the grid control using the value goEditing. Use the value goAlwaysShowEditor to always display the cell Editor.

Indicates whether columns are automatically resized to fill the visible area in the grid.

AutoFillColumns is a Boolean property which enables or disables automatic sizing for columns on the grid control. The default value for the property is False, and indicates that automatic column sizing is not enabled.

Changing AutoFillColumns to True causes the column sizes to be recalculated (and cached) based on default values, or using properties assigned to the TGridColumn instances when the Columns collection has been Enabled. The resizing algorithm works as follows:

  • Fixed Columns are not resized.
  • When Columns has not been Enabled, or the column position is not found in Columns, a default sizing priority of 1 is used along with the minimum and maximum sizes defined in the DEFMINSIZE and DEFMAXSIZE constants.
  • When Columns is Enabled, and a column exists at a given position, values from the TGridColumn instance are used including: SizePriority, MinSize, and MaxSize.
  • A column with a SizePriority of 0 is not resized.
  • A column with a non-zero value in SizePriority is adjusted using the average available width with respect to the MinSize and MaxSize for all of the defined columns.
  • If Columns is not Enabled or populated, or all columns have a SizePriority of 0, the last column in the grid is resized to the available width.

Note that TGridColumn instances in Columns are initially created with SizePriority set to 1. For TDbGrid, which automatically populates Columns, this means the user will not be able to resize these columns using the mouse (since they are auto-sized).

Use ColWidths to set the width for a specified column when the Columns collection has not been enabled or populated.

Drawing style used for the borders on the control.

BorderStyle is a TBorderStyle property with the drawing style used for the borders around the control. BorderStyle uses a restricted range of values found in TFormBorderStyle: a single border (bsSingle) or none (bsNone). Changing the property value causes UpdateBorderStyle to be called.

Use EditorBorderStyle to set the border drawing style for cell Editor controls on the grid.

BorderStyle is used in the ancestor class to determine the creation parameters passed to the widgetset class instance.

TBorderStyle TFormBorderStyle TWinControl.BorderStyle
The color used for the border on the control.

BorderColor is a TColor property with color used when drawing the borders around the grid control. The default value for the property is cl3DDKShadow. Changing the value for the property causes the control to be redrawn when BorderStyle is bsSingle.

BorderColor is used in the DrawBorder method to set the Pen color in Canvas prior to drawing the borders on the control.

TColor
Identifies how text is combined to form the Hint property.

CellHintPriority is a TCellHintPriority that identifies how text is combined to form the Hint property. The default value for the property is chpAllNoDefault. See for a description of the enumeration values and their meanings.

CellHintPriority is used in the implementation of the ShowCellHintWindow, MouseMove, and GetTruncCellHintText methods.

Column index for the selected grid cell.

Col is an Integer which holds the column index for the current cell or grid cursor. The current grid column can be changed programmatically by setting a new value in this property.

Setting a new value for the property causes the limits for the column index to be checked when AllowOutboundEvents is set to False. An exception is raised in the CheckLimitsWithError method when the property value is not a valid column index for the grid control.

MoveExtend is called to move the selection to the cell at the coordinates in Row and Col. The cell editor is also retrieved (when available) and is displayed. The Click method is called to signal the OnClick event handler (when assigned) if the cell is not already selected or displaying a cell editor.

Number of columns in the grid.

ColCount is an Integer that represents the number of columns in the grid, including fixed and normal columns. Changing the value in ColCount after Columns have been created causes an EGridException to be raised. Use the Columns collection to add or delete columns defined in the grid.

Use FixedCols for the number of fixed columns in the grid.

Use VisibleColCount for the number of non-fixed columns in the grid.

Use RowCount, FixedRows, and VisibleRowCount to access the row-oriented equivalents.

Raises an EGridException when the value is changed and Columns already exist in the grid.
Provides access to current column and row numbers as a TPoint instance.

ColRow is a TPoint property used to provide access to the current values at the position specified in Col and Row. The X member in TPoint is used for the value in the Col property. The Y member in TPoint is used for the value in the Row property.

Setting the value for the causes the CheckLimitsWithError method to be called for the X and Y values when AllowOutboundEvents is False. The SetColRow method is called to update the values in the Col and Row properties.

Cursor shape displayed when a column or row is dragged in the grid control.

ColRowDraggingCursor is a TCursor property with the cursor shape displayed when a column or a row in the grid control is dragged. It is displayed in methods which perform column or row drag operations at run-time when the CursorState property is set to gcsDragging. The default value for the property is crMultiDrag (multiple item drag cursor TCursor(-16)).

ColRowDraggingCursor is a published property in descendent classes like: TDrawGrid, TStringGrid, and TDBGrid.

Use ColRowDragIndicatorColor to specify the color for the drag cursor when a drag operation is active.

Use ColSizingCursor to specify the cursor shape displayed when a column is resized by dragging the column border.

Color used to render the drag cursor when a column or row is dragged in the grid.

ColRowDragIndicatorColor is a TColor property with the cursor color used when the ColRowDraggingCursor is visible for the grid control. The default value for the property is clRed.

Changing the property value causes the DrawColRowMoving method to be called when the grid state is set to gsColMoving.

ColRowDragIndicatorColor is a published property in descendent classes like: TDrawGrid, TStringGrid, and TDBGrid.

Use ColRowDraggingCursor to specify the cursor shape displayed when a column or row drag operation is active.

Use ColSizingCursor to specify the cursor shape displayed when a column is resized by dragging the border on a column.

Cursor shape displayed when a column is resized.

ColSizingCursor is a TCursor property with the cursor displayed when the horizontal size for a column is changed. The default value for the property is defined in the crHSplit constant.

It is displayed when a mouse down event causes the grid cursor state to be changed to the value gcsColWidthChanging.

Use RowSizingCursor to specify the cursor shape displayed when a row height is changed.

crVSplit
Indicates if clicking a column header changes its sort order.

ColumnClickSorts is a Boolean used to indicate if clicking a column header changes its sort order. The default value for the property is False.

ColumnClickSorts is used in the HeaderClick method to determine if the value in the SortOrder is toggled for a click in the header cell for SortColumn.

Definitions for the columns displayed the grid.

Columns is a TGridColumns which contains column definitions for the grid control. Columns stores the TGridColumn instances which define the attributes for each of the columns such as its Font, Color, Alignment, Layout, Editor style, auto-sizing priority, et. al. Properties and methods in Columns can be used at run-time to access and maintain the column definitions for the grid.

See TGridColumn for more information about the items stored in the collection.

Columns contains definitions for the non-fixed columns on the grid control. For a grid with 5 columns, and FixedCols set to 1, there would need to be 4 definitions added to the Columns collection. ColCount is automatically maintained when items are added to or deleted from Columns. When Columns is enabled, a value cannot be directly assigned to ColCount; it is calculated as:.

ColCount := FixedCols + Columns.Count

Values in the collection can be modified at run-time to add, delete, or modify column definitions. For example:

var c: TGridColumn; begin // add a custom column c := Grid.Columns.Add; // modify the new column c.title.caption := 'Price'; // Set columns caption c.align := taRightJustify; // Align column content to the right c.color := clMoneyGreen; // Change default color to clMoneyGreen c.Index := 0; // Make it the first column // access an existing column grid.columns[0].Width := 60; // Change column 0 width to 60 pixels // delete an existing column grid.columns.delete(0); // Delete column 0 .... end;

Columns should not be confused with the COLUMNS construct frequently used in SQL programming, which refer to Fields in a database table. The content in fields can be displayed as Columns in a Grid, but they must be seen as separate and distinct. It is irrelevant to refer to the color, font or width of a data field from a database - but these are all very relevant in specifying the appearance of a column in a grid.

Provides indexed access to the Width for a column in the grid.

The column is specified with the aCol parameter. The aCol parameter must fall within the valid index range of 0 to ColCount-1.

The property value is the width of the specified column in pixels.

The initial width for a newly created column is specified with the DefaultColWidth property.

If the Options property includes the value goColSizing, the column width may also be changed by the user at run-time.

Ordinal position for the column. It allows access to all fixed columns including the initial column (0) normally used for row indicators or line numbers. Default width used for grid columns.

DefaultColWidth is an Integer property with the default width for a new column added to the grid control. If new columns of the grid are created by changing the ColCount property, the width of these new columns will be set to the value in the DefaultColWidth property.

A negative non-zero value in the property member indicates that the value in the DEFCOLWIDTH constant is scaled to the PPI setting for the Font used on the control. Use 0 as the width for an auto-sized column. Changing the value for the property causes existing values in Cols to be reset to -1 to force the columns to be scaled and updated. The position for a visible Editor control is also updated when the property value is changed.

DefaultColWidth is used as the default when reading values from the indexed ColWidths property.

Default row height for newly created grid rows.

If new rows of the grid are created by changing the RowCount property, the height of these new rows will be set to the value of the DefaultRowHeight property.

Use 0 for auto-sized row heights.

Indicates if the default drawing mechanism is used to draw the background and text for cells.

DefaultDrawing is a Boolean property which indicates if the default drawing mechanism is used to draw the background and text for the cells on the grid control. The default value for the property is True.

Normally, the grid prepares its canvas using the properties needed for the kind cell type that is being painted. DefaultDrawing indicates that the grid control handles drawing the background and text for the cell (including a visible cell Editor) using the relevant properties.

Use the OnDrawCell event handler to handle drawing a cell using an appearance different than the default provided in PrepareCanvas. When DefaultDrawing is set to False, the OnDrawCell event handler is responsible for both the background and text content in the cell.

Changing the value for the property causes the Invalidate method to be called to redraw the control.

DefaultDrawing is used in the PrepareCanvas method to configure the control Canvas for a drawing operation. It is also used in the DrawCell method in descendent classes.

Default style used to display text including alignment, layout, wrapping, et. al.

DefaultTextStyle is a TTextStyle property with the default settings used for text displayed on the grid control. It includes settings like:

  • Horizontal and vertical alignment.
  • Use of line breaks or wrapping.
  • Use of clipping for the text rectangle.
  • Converting Tab characters to spaces.
  • Display of Accelerator or shortcut prefixes.
  • Opacity for the background color and text.
  • Use of the system font.
  • Right-to-left alignment.
  • Text shortening using an Ellipsis character.

DefaultTextStyle is used in the PrepareCanvas method. It is merged with state, color, and options in the control and assigned to the TextStyle property in Canvas.

TTextStyle TCustomControl.Canvas
Color used to draw text in the grid when Enabled is set to False.

DisabledFontColor is a TColor property with the color used to render text on the grid control when Enabled is set to False. The default value for the property is clGrayText.

DisabledFontColor is used in the PrepareCanvas method to set the font color on the Canvas when Enabled is False. It is not used in the Canvas font when it contains clNone.

TColor TCustomControl.Canvas TControl.Enabled
The amount (DeltaX) by which an object should be dragged. The editor control used to modify the value in the current cell.

Editor is a TWinControl descendant which contains the control used to edit the value in the current cell for the grid control.

There are several editor styles available for columns on the grid control: String, Button, Composite, and Pick List. Button editors display a button that can be clicked to perform actions which determine the value for the cell. A composite editor uses an editor for the string value and a button to perform additional actions. A pick list editor allows selection from one of the predetermined values for the cell. The String editor is essentially a TEdit control, and is the default editor style used in the grid control.

The Editor style is determined either by examining values in the column definition stored in the Columns property, or using the OnSelectEditor event handler. OnSelectEditor is signalled when Columns has not been Enabled in the grid.

Editor display behavior is controlled by properties like Options and AutoEdit.

Options can be used to enabled / disabled cell editor features using the following:

goEditing
Cell editing is allowed for the grid control. Omit to disable cell editing.
goAlwaysShowEditor
The cell editor for the current cell is always displayed. Omit to disable. The cell editor can be toggled using F2, Enter, or a mouse click in the current cell.

The AutoEdit property determines whether a cell is automatically placed in edit mode as soon as it is selected. This is basically the same as including goAlwaysShowEditor in the Options property.

The border style for the Editor control.

EditorBorderStyle is a name property which contains the border style used for the Editor in the grid control. The value for the property depends on the editor style used for the cell in the grid.

When TStringCellEditor, TCompositeCellEditor, or TPickListCellEditor are used for the cell, the property value is read from the BorderStyle in the editor control. For all other editors (TButtonCellEditor), the value bsSingle is returned as the property value.

Setting a new value for the property causes the BorderStyle for the Editor to be updated, and the EditorPos method is called to recalculate the editor bounds and position.

Setting the property to bsSingle forces a border to be drawn inside the cell rectangle where the control is located. For some widgetsets, the border is drawn using theme services to maintain a uniform appearance for the platform.

True when the Editor is ready to modify the value for the current cell.

EditorMode is a Boolean property which indicates whether the cell Editor has been enabled for the grid control. Set EditorMode to True to display the cell Editor for the control. Set it to False to hide the cell Editor.

The value in EditorMode is updated when handling key press and mouse click events, scrolling the visible area for the control, or changing the configuration settings for the grid.

Indicates if the last key event was triggered by the cell Editor for the grid control.

EditorKey is a Boolean property which indicates if the last key event was generated by the cell Editor for the grid control. The property value is updated in the OnKeyDown, OnKeyPress, and OnKeyUp event handlers used in the Editor control. Its value is used in method like KeyDown, KeyPress, and KeyUp to determine whether a given key needs to be applied / handled for the grid control.

The option flags sent to the Editor control in the grid.

EO_HOOKKEYDOWN enables the OnKeyDown event handler in the editor control. EO_HOOKKEYPRESS enables the OnKeyPress event handler in the editor control. EO_HOOKKEYUP enables the OnKeyUp event handler in the editor control.

True when the cell Editor for the grid control has been displayed.

EditorShowing is a Boolean property which indicates if the cell Editor for the control has been displayed. The property value is updated in methods like EditorShow and EditorHide when the visibility for the Editor control is changed.

The property value is used in several methods which handle key events, mouse clicks, and focus changes in the control.

Indicates if extended column sizing is enabled in the grid. Indicates if extended row sizing is enabled for rows in the grid.

ExtendedRowSizing is a Boolean property which indicates if extended row sizing is enabled for the grid control.

ExtendedRowSizing is not maintained in any methods in the class implementation. It is used in DoRowSizing only.
Indicates whether a selection can extend beyond the visible boundary for the grid. Indicates if "Fast Editing" is enabled in the grid.

FastEditing is a Boolean property which indicates if cell editing initialized by a KeyDown message instead of by a navigation key is used in the grid control. The value in FastEditing is used when a TPickListCellEditor handles KeyDown messages.

The default value for the property is True as assigned in the Create constructor.

Indicates if alternate row coloring starts with the normal row color.

AltColorStartNormal - using a second color to display alternate rows, but starting the first row with the normal color.

Using a different color for the background of alternate rows often makes the data in a grid much easier to read.

The number of fixed columns in the grid.

FixedCols is an Integer property with the fixed column count for the grid. Fixed columns are displayed on the left edge of the grid and become part of the non-scrolled area for the control. A fixed column is displayed using the background color in FixedColor and separator lines using FixedGridLineColor. They are also rendered using the display style attributes in TitleStyle.

Values in a fixed column cannot be selected or edited using a cell editor at run-time. They can be modified, however, in descendent classes like TStringGrid by assigning values directly to the Cells property for the required column number.

The default value for the FixedCols property is 1 and causes the first column (column 0) (the one reserved for row indicators or automatic row numbering) to always be visible on the left edge of the control. Cell data in adjacent column can be converted to fixed column by incrementing the value for the property.

Setting a new value for the property causes several actions to be performed for the grid control.

  • The values in FixedCols and FixedRows are verified by calling CheckFixedCount, which can raise an exception if either value is not in range for the grid control.
  • EditorMode is set to False to hide a visible cell Editor for the control.
  • When Columns has been Enabled, UpdateSelectionRange is called to refresh the selection rectangle for the control. ColumnsChanged is called to apply the visual change to the control. If Columns has not been Enabled, MoveNextSelectable and UpdateSelectionRange are called to refresh the grid control.

Use FixedRows to get or set the number of fixed rows displayed for the grid control.

Use the Columns property to maintain column definitions for the non-fixed columns on the control. If a column definition in Columns needs to be changed to a fixed column, it must be removed from the Columns collection before increasing the value in FixedCols. An Exception is raised if FixedCols + Columns.Count does not match the value in ColCount.

Number of the fixed rows in the grid.

Contains the fixed row count for the grid control. A fixed row with fixed columns is normally used to display the headings (titles), images, and sort indicators for the columns in the grid control. The fixed row containing the fixed columns is not scrolled along with the visible area for grid.

Setting a new value for the property causes several actions to be performed for the grid control.

  • The values in FixedCols and FixedRows are verified by calling CheckFixedCount, which can raise an exception if an error condition is detected.
  • EditorMode is set to False to hide a visible cell Editor for the control.
  • MoveNextSelectable is called to find the first selectable cell in the current column. UpdateSelectionRange is called to refresh the cell selected in the grid control.

Use FixedCols to get or set the number of fixed columns displayed for the grid control.

The color used for the fixed cells in the grid.

FixedColor is a TColor property with the color used to paint the background for fixed cells in the grid control. The default value for the property is clBtnFace. Changing the value in FixedColor causes the Invalidate method to be called to redraw the control.

Use Color to specify the background color for non-fixed cells in the grid control. Use AlternateColor to specify the background color used for alternate rows in the grid control.

Use the Color property in Font to specify the color used for text drawn in the cells for the grid. Use DisabledFontColor to specify the color used for text when the control is disabled.

Other colors can be supplied using properties including: BorderColor, GridLineColor, FixedGridLineColor FixedHotColor, FocusColor, and SelectedColor.

Color used to draw the separator lines for fixed grid cells.

The default value for the property is cl3DDKShadow as assigned in the constructor. Changing the value in FixedGridLineColor causes the grid to be redrawn.

FixedGridLineColor is used in the implementation of the DrawCellGrid method. The color is not used (or needed) when GridLineWidth contains the value 0 (zero).

The color used for hot-lighted fixed cells in the grid.

FixedHotColor is a TColor property used to draw the background for a fixed cell that is under the mouse pointer (or hovered).The default value for the property is cl3DLight.

FixedHotColor is used in the PrepareCanvas method when header hot tracking is enabled in Options (goHeaderHotTracking) and gdHot is included in the drawing state for the specified cell. The property value is assigned as the brush color for the Canvas in the control.

TColor
Indicates if cells are displayed using a Flat appearance.

Flat is a Boolean property which indicates if the cells on the control are drawn using a "flat" drawing style. This causes the cells, including fixed headers, to have a thinner single-line border without any 3D relief regardless of the setting in TitleStyle.

The default value for the property is False. Changing the value in Flat causes the UpdateBorderStyle method to be called when BorderStyle is set to bsSingle. Invalidate is called and causes the control to be redrawn.

Flat is used in the DrawBorder method to determine the border drawing style and Canvas settings needed for the control.

The color used to draw the focus rectangle when a cell has focus.

FocusColor is a TColor property with the color used to draw the focus rectangle (or rubber band) for the focused cell in the grid control. The default value for the property is clRed. Changing the value for the property causes the current in Col and Row to be redrawn.

FocusColor is used in the DrawFocusRect method when DefaultDrawing is enabled for the grid control. But it is not used when UseXORFeatures is enabled; clWhite is used as the pixel color instead.

Indicates if the focus rectangle is displayed for the control.

FocusRectVisible is a Boolean property which indicates if the focus rectangle (or rubber band) is drawn for the focused cell, extent, or row in the grid control. Changing the value for the property causes the grid control to be redrawn. The default value for the property is True as assigned in the Create constructor.

FocusRectVisible is used in the DrawRow method when the current cell or extent is redrawn. If row selection (roRowSelect) is included in the Options for the grid, the focus rectangle is drawn for the entire row.

Set FocusRectVisible to False to disable the feature in the control.

Contains cached data about the visual layout and state for the grid control. Contains grid-specific state flags active for the control.

GridFlags is a TGridFlags property which contains values that indicate the state or status for the grid control or its editor. It is a set type and may contain zero (0) or more values from the TGridFlagsOption enumeration.

Values are included in or excluded from the set as needed during execution of methods in the grid control. See TGridFlagsOption for more information about the values in the enumeration and their meanings.

Total height for all of the rows in the grid control.

GridHeight is a read-only Integer property which contains the calculated height for all of the rows in the grid control. Its value is provided using the cached values stored in GCache when row or column sizes are calculated for the control.

Color used for the grid lines on the control.

GridLineColor is a TColor property with the color used to draw the grid lines between rows and columns on the control. The default value for the property is clSilver. Changing the value for the property causes the grid control to be redrawn.

GridLineColor is used in the DrawCellGrid method to draw the lines around non-fixed cells when GridLineWidth has a non-zero value.

Use FixedGridLineColor to set the color used to draw grid lines around fixed rows and columns on the control.

Style used to draw the grid lines on the control.

GridLineStyle is a TPenStyle property with the pen drawing style used to draw grid lines on the control. The default value for the property is psSolid. Changing the value for the property causes the grid control to be redrawn.

GridLineStyle, GridLineWidth, GridLineColor, and FixedGridLineColor are used in the DrawCellGrid method when GridLineWidth is set to a positive non-zero value.

TCanvas.Pen TPen.Style TPenStyle
Width (thickness) for grid lines drawn on the control.

GridLineWidth is an Integer property which contains the thickness for the grid lines drawn on the control.

The default value for the property is 1, and causes a single pixel to be used when drawing grid lines. Changing the value for the property causes the grid control to be redrawn.

GridLineWidth is used in the DrawCellGrid method when grid lines are drawn for both fixed and non-fixed cells. Set GridLineWidth to 0 to suppress drawing of grid lines on the control.

Total width for all columns in the Grid including non-visible columns.

GridWidth is a read-only Integer property which contains the calculated width for all of the columns in the grid control, including columns with the visible property set to False. Its value is provided using the cached values stored in GCache when row or column sizes are calculated for the control.

Contains the grid zones which are hot-lighted (hovered) on the control.

Other than setting the default value for the property, HeaderHotZones is not used in the current LCL implementation.

Contains the grid zones which are drawn in a "pushed" state on the control.

HeaderPushZones is a TGridZoneSet property which indicates which areas on the control are drawn in a "pushed" state when they are clicked. It is a set type and contains zero or more values from the TGridZone enumeration. The default value for the property is [gzFixedCols], and indicates that fixed header cells are drawn with a button down state when they are clicked.

HeaderPushZones is used in the MouseDown method when a mouse down event is cached for the grid control. It is relevant when goHeaderPushedLook has been included in the Options for the control, and causes the cell under the mouse pointer to be redrawn in a clicked or pushed state when the mouse event is handled.

Ordinal position for the image used when a column is sorted in ascending order.

ImageIndexSortAsc is a TImageIndex property with the ordinal position in TitleImageList for the image drawn in the header for a column sorted in ascending order. The default value for the property is -1 and indicates that a value has not been explicitly assigned for the property.

The property value is not used in the current LCL implementation. Use the ImageIndex property in a TGridColumnTitle instance instead.

TImageIndex
Ordinal position for the image used when a column is sorted in descending order.

ImageIndexSortDesc is a TImageIndex property with the ordinal position in TitleImageList for the image drawn in the header for a column sorted in descending order. The default value for the property is -1 and indicates that a value has not been explicitly assigned for the property.

The property value is not used in the current LCL implementation. Use the ImageIndex property in a TGridColumnTitle instance instead.

TImageIndex
Controls the behavior for Tab navigation in the grid control.

TabAdvance is a TAutoAdvance property used to determine the behavior for Tab key navigation in the grid control. The default value for the property is aaRightDown, and indicates the Tab key moves the selected cell to the right and then to the first column in the next row. A Shift+Tab key press results in the reverse of this behavior. See TAutoAdvance for the other enumeration values and their usage.

TabAdvance is relevant when goTabs has been included in the Options for the grid control. Otherwise, the Tab key causes the next control to become focused.

TabAdvance is used in the implementation of the KeyDown method in TCustomGrid.

The list with images displayed in column titles.

TitleImageList is a TImageList property which contains the images displayed in the title area for columns in the grid. It can include images used for the non-native column sort indicators.

Setting a new value for the property causes the VisualChange method to be called to update the column sizes and redraw the control.

TitleImageList is used to get an image resolution using the width specified in TitleImageListWidth. The images are used when rendering the TGridColumn instances in the Columns collection.

Stores the default width for images used in the title area for fixed cells.

TitleImageListWidth is an Integer which stores the default width for images used in the title area for fixed cells. The default value for the property is 0. Changing the value in TitleImageListWidth causes the VisualChange method to be called to update the grid control.

The value in TitleImageListWidth is used in methods which draw fixed cells in the grid, such as:

  • DrawColumnTitleImage
  • AutoAdjustColumn
  • GetSortTitleImageInfo
Cell editor for the grid control.

InplaceEditor is a read-only TWinControl property that represents the cell Editor for the control. Read access is redirected to the member variable used for the Editor property. It is provided for Delphi code compatibility. Use the Editor property instead.

Provides indexed access to the selected state for a cell by its column and row number.

IsCellSelected is an indexed Boolean property which provides access to the selected state for a cell using its column and row number. ACol and ARow contain the column and row number for the cell.

Compares the cell coordinates in ACol and ARow to the current Selection in the grid control. The return value is True if the cell is in the cell range in Selection.

If RangeSelectMode is set to rsmMulti, all of the existing range selections are examined for the specified cell. The property value is True when the cell is located in the array of rectangles used for multi-selections in the grid control.

Otherwise, the property value is set to False.

True when the cell at the specified column and row is selected. Column number for the cell examined in the method. Row number for the cell examined in the method. Column number for the first visible column on the left edge of the grid. Sets the mouse wheel behavior for the grid control.

MouseWheelOption is a TMouseWheelOption used to set the mouse wheel behavior for the grid control. The default value for the property is mwCursor, and indicates that mouse wheel movements change the cursor position on the screen. Use mwGrid to cause mouse wheel movements to change the active selection in the grid control.

Contains the set of optional features and/or behaviors enabled for the grid control.

Options is a TGridOptions property used to store the options enabled for the grid control. Values from the TGridOptions enumeration are included in the set type to enable specific features or behaviors.

The set values can be included or excluded at design-time using the object inspector in the Lazarus IDE. They can also be included or excluded in the set at run-time using program code. The default value for the Options property is defined in the DefaultGridOptions set constant.

Values present in the set cause the corresponding features or behaviors to be enabled in the control at run-time. For the complete list of available options and their usage, see .

Use Options2 to set scrolling or cell editor behaviors enabled for the grid control.

Use MouseWheelOption to control mouse wheel behavior in the grid control.

Contains additional options for scrolling and editor behavior enabled in the grid control.

Options2 is a TGridOptions2 property which contains options which control scrolling or cell editors in the grid control. It is a set type which contains zero (0) or more values from the TGridOption2 enumeration.

See TGridOption2 for the values allowed in the set type. The default value for the property is defined in the DefaultGridOptions2 constant (it is an empty set).

The set values can be included or excluded at design-time using the object inspector in the Lazarus IDE. They can also be included or excluded in the set at run-time using program code.

Values present in the set cause the corresponding behaviors to be enabled in the control at run-time. For example:

goScrollToLastCol
Allows columns to be scrolled until the last column is the LeftCol for the grid control.
goScrollToLastRow
Allows rows to be scrolled until the last row is the TopRow for the grid control.
goEditorParentColor
Sets the color in a cell editor to the color in the parent control (the TCustomGrid instance). Changing the set member does not affect an existing cell editor already visible on the control. The change is applied when the next cell editor is created and displayed.
goEditorParentFont
Sets the font in a cell editor to the font in the parent control (the TCustomGrid instance). Changing the set member does not affect an existing cell editor already visible on the control. The change is applied when the next cell editor is created, configured, and/or displayed.

Use Options to control the primary features and behaviors in the grid control.

Use MouseWheelOption to control the mouse wheel behavior in the control.

Modified in version 2.4 to include goEditorParentColor and goEditorParentFont options.
Controls the range selection mode used for the grid.

RangeSelectMode is a TRangeSelectMode property that controls the range selection mode used for the grid. The default value for the property is rsmSingle, and allows selection of a single cell in a range. Use rsmMulti to select multiple cells in a range selection.

Changing the value in RangeSelectMode causes the ClearSelections method be called to remove existing selection(s) in the grid control.

RangeSelectMode is used in the implementation of methods like:

  • AddSelectedRange
  • GetIsCellSelected
  • MouseDown
  • InvalidateCell
Row number for the selected grid cell.

Row is an Integer property which contains the row index for the currently selected cell in the grid control. The value in Row is zero-based, and cannot exceed the value RowCount-1.

Setting a new value for the property causes the values in Col and Row to be validated against the ColCount and RowCount for the grid. Error checking is used, and an exception may be raised if the new property value is not in the limits for the control. The selected cell in the control is changed to (or extended to) the new values in the Col and Row properties. The Click method is called to signal the OnClick event handler (when assigned) if the cell is not already selected or displaying a cell editor.

Use Col to determine the column number for the currently selected cell in the grid control.

Number of rows in the grid.

RowCount is an Integer property which contains the number of rows in the grid control, including fixed and normal rows.

Changing the value in RowCount causes a visible Editor in the control to be hidden, and EditorMode is set to False. When the Columns collection is Enabled, the ColumnsChanged method is called. Setting RowCount to 0 (zero) causes the ClearRows method to be called.

Use ColCount to access the number of columns for the grid control when Columns has not been enabled.

Use Col and Row for the current cell selected in the control.

Cursor shape displayed when the row height is resized.

RowSizingCursor is a TCursor property with the cursor displayed when the vertical size for a row is changed. The default value for the property is defined in the crVSplit constant.

It is displayed when a mouse down event causes the grid cursor state to be changed to the value gcsRowHeightChanging.

Use ColSizingCursor to specify the cursor shape displayed when a column width is resized.

crVSplit
Provides indexed access to the height for each row in the grid.

The row is specified with the aRow parameter. The aRow parameter must fall within the valid index range of 0 to RowCount-1.

The return value of the is the height of this row, measured in pixels.

The initial height of a newly created row is specified with the DefaultRowHeight property. After that the user may redefine this value. If the Options includes the appropriate value, the row height may also be changed by the user at run-time.

Row number affected in the method. Options which control the information saved and loaded for the grid control.

SaveOptions is a TSaveOptions property with the set of options enabled when saving values in the grid to a file or stream. The options indicate whether design-time information, column attributes, cell content and positions are included in the values save for the grid control. The TSaveOption values included in or excluded from the property affect the following:

soDesign
Design-time information for the control, including: column count, row count, number of fixed columns and rows, default column width, default row width and height, color, column definitions (when enabled in the control), and row heights with non-default values. Also includes the settings in the Options and Options2 properties for the control.
soPosition
Run-time values for the top and left coordinates for the grid, and the current column and row number.
soRangeSelect
Requires the soPosition option. Stores the left, top, bottom, and right coordinates for the range in the Selection property.
soContent
Stores the UTF-8-encoded text for each of the cells in the grid control.

The default values in SaveOptions are not assigned in TCustomGrid, and must be provided in a descendent class like TCustomStringGrid.

SaveOptions also determines the data available and processed when loading grid information in the LoadFromFile or LoadFromStream methods.

Indicates if a Selection is active in the grid control.

SelectActive is a Boolean property which indicates if a Selection range is active in the grid control. It is set to True when a cell or range of cells is selected using the keyboard or mouse navigation, or by assigning a value to the Selection property. It is set to False in methods like CancelSelection, DoExit, and DoMouseWheel.

Color used for selected cells in the grid.

SelectedColor is a TColor property which contains the color used for the background in selected cell(s). SelectedColor is used in PrepareCanvas to set the brush color for the control Canvas when IsSelected is True. The default value for the property is clHighlight as assigned in the constructor for the class instance.

Changing the value in SelectedColor causes the Invalidate method to be called to redraw the control.

Indicates if a special color is used for selected cells when the control loses focus.

FadeUnfocusedSelection is a Boolean property which indicates if inactive caption and text colors are used to draw the selected cells in the grid when the control loses focus. It causes color values for the Brush and Font on the Canvas to be updated.

When set to True and the control is not Focused, an sRGB color difference between the Font color and the clBtnFace color is used to select the color values applied to the Canvas. If the color distance at least 25%, clBtnFace is used for the background and clBtnText is used for the text. For a smaller color distance, clInactiveCaption is used for the background and clInactiveCaptionText is used for the text.

When set to False, or when the control has Focus, the color in SelectedColor is used for the background in selected cells and the color assigned to Font is used for text.

The default value for the property is False. Changing the value for the property causes the control to be redrawn.

FadeUnfocusedSelection has no effect on cells which use a button-style editor; they are drawn using the style and color values needed for the button control.

FadeUnfocusedSelection is used in the PrepareCanvas method to assign the Brush and Font colors used on the Canvas.

TCustomControl.Canvas clBtnFace clBtnText clInactiveCaption clInactiveCaptionText
The column instance for the currently selected cell in the grid control.

SelectedColumn is a read-only TGridColumn property which contains the column instance for the current column. Col contains the column number for the selected cell in the grid control, and is used to located the column instance by calling ColumnFromGridColumn. The property may contain Nil if Columns has not been enabled in the control, or when a valid column definition is not found for the current column number.

Rectangle with the current cell selections in the grid control.

Selection is a TGridRect property with the column and row numbers for the current cell selection in the grid control. The Left and Right members in the property value are column numbers for the cells in the selection. The Top and Bottom members in the property value are row numbers for the cells in the selection.

Selection is used when goRangeSelect has been included in the Options for the grid.

When a new grid rectangle is assigned for the property, the member values in the rectangle are normalized to ensure they are in the acceptable range of values for the grid control. If all four members have negative values, the current Selection is cleared by calling ClearSelection.

Column or row numbers in the rectangle are adjusted to exclude FixedCols and FixedRows.When goSelectionActive has been included in the grid Options, the current selection is extended to include the new selection range. The Invalidate method is called to redraw the grid control with the new Selection value.

A value assigned to Selection is ignored when goRangeSelect has not been included in the Options for the grid.

Scrollbars displayed for the grid control.

ScrollBars is a TScrollStyle property which indicates the scroll bars displayed for the grid control. The default value for the property is ssAutoBoth and causes vertical and horizontal scroll bars to be displayed when needed.

See TScrollStyle for more information about values in the enumeration and their meanings.

TScrollStyle
Indicates if strict sorting is used.

StrictSort controls whether the internal QuickSort routine can skip exchanging the position for items when they have the same sort values. It allows the sort routine operate more quickly. Set StrictSort to False to skip calling the exchange routine for the items with the same values. When set to True, the exchange operation is performed for all sorted items.

The font used for text in a column title.

TitleFont is a TFont property with the font used for the text in a fixed column title. By default, TitleFont uses the same Font assigned to the grid control.

The OnTitleFontChanged event handler is used as the OnChange event handler for TitleFont, and ensures that updates to TitleFont are also applied to TGridColumn instances in the Columns collection (when enabled). In addition, the font in TitleFont is ignored when Columns has been Enabled; the Font assigned to the Title property for the TGridColumn instance is used instead.

GetColumnFont is called from PrepareCanvas to determine whether TitleFont or a font defined in the Columns collection is used to render the text in fixed cells.

Assigning a new value to TitleFont causes the VisualChange method to be called to recalculate column sizes in the grid control.

Font sizes (in both Font, TitleFont, and TGridColumn instances) may be scaled at run-time to provide support for high density displays. See ScaleFontsPPI for more information.

The drawing style used for the fixed column titles.

TitleStyle is a TTitleStyle property which contains the drawing style used when rendering the fixed cells with the column titles. Changing the value in TitleStyle cause the Invalidate method to be called to redraw the grid control.

TitleStyle is used in the DrawCellGrid and DefaultDrawCell methods when Flat is set to False, and controls the 3D appearance of the fixed cell.

tsLazarus
Uses the default appearance common to the supported platforms in Lazarus.
tsNative
Uses the drawing style for the current widgetset or theme.
tsStandard
Uses a more contrasted look similar to Delphi grids.

Use TitleFont (or the definitions in the Columns collection) to control the font used in fixed cells.

The first visible row in the grid.

TopRow is an Integer property with the position of the first row visible in the control. Rows are numbered from 0 to RowCount-1 but the first accessible row is at the ordinal position in FixedRows. In short: when FixedRows is 1, row number 0 is not accessible. When FixedRows is 2, row numbers 0 and 1 are not accessible. Ad infinitum.

Setting a new value for the property causes the grid to scroll until the specified row number becomes visible. The current column a selection is not affected. No actions are performed if the row is already visible (even if it is not the first visible row).

The property value is read from and written to the cached internal TopLeft member for the control.

Use ScrollToCell to make the cell at a specific column and row number become visible in the grid control.

When True, the dotted focus rectangle is painted using an XOR raster operation.

This controls how the dotted focus rectangle appears in the grid. When True, the rectangle is painted using an XOR raster operation. This allows the focus rectangle to be seen regardless of the cell background color. When False, the user can control the color of the dotted focus rectangle using the FocusColor property.

It also controls the look of column/row resizing operations. When True, a line shows visually the size that the the column or row will have if the user ends the operation. When False, the column or row resizing takes effect as the user drags the mouse.

Controls validation when the text for the selected cell is changed.

ValidateOnSetSelection is a Boolean property used to control validation performed when the text for the selected cell is changed in the grid. The default value for ValidateOnSetSelection is False, as assigned in the constructor for the class.

ValidateOnSetSelection is used in the SelectionSetText method to determine if the ValidateEntry method is called to validate the content in the cell.

The number of visible columns in the grid control.

VisibleColCount is a read-only Integer property with the number of columns displayed in the visible area for the control. The property value is derived using the cached VisibleGrid information in the GCache property. It is not included in the LCL streaming mechanism, and is an artifact from older LCL versions.

The number of visible rows in the grid control.

VisibleRowCount is a read-only Integer property with the number of rows displayed in the visible area for the grid control. The property value is calculated using the cached visible area in the GCache property.

Use VisibleColCount for the number of columns displayed in the visible area for the grid control.

Event handler signalled after a new Selection is made in the grid.

OnAfterSelection is a TOnSelectEvent property that is the event handler signalled when the Selection for the control has been moved.

An application can implement and assign an object procedure using the event signature to perform any action needed for the notification. The arguments passed to the event handler include the column and row numbers prior to moving the Selection .

Event handler signalled before changing the Selection in the grid control.

OnBeforeSelection is a TOnSelectEvent property with the event handler signalled prior to changing the Selection for the grid control. OnBeforeSelection can be used to perform actions needed before the Selection is moved and an Editor is displayed for the newly selected cell.

OnBeforeSelection is triggered (when assigned) from the MoveExtend method, and occurs when a new column or row is selected in the grid using keyboard navigation, using the mouse, or by assigning values to the Col or Row properties. It is also triggered when an explicit value is assigned to the Selection property.

Use OnAfterSelection to performs actions needed after the Selection has been changed and the Editor has been displayed.

Event handler signalled when the value for a check box cell is toggled.

OnCheckboxToggled is a TToggledCheckboxEvent property with the event handler signalled when the value for a check box-style cell is toggled. OnCheckboxToggled is triggered (when assigned) after the cell value has been changed and stored. OnCheckboxToggled is used in descendent classes which implement a method to toggle the value when the cell is clicked, like TCustomDrawGrid.

Event handler signalled to compare the content in grid cells.

OnCompareCells is a TOnCompareCells property with the event handler signalled to compare two cell values in the grid control. OnCompareCells is signalled (when assigned) by the DoCompareCells method, and occurs when column or row values are examined in the Sort method. The Result parameter contains the relative sort order for the compared cell values.

Event handler signalled to prepare the Canvas to draw the grid.

OnPrepareCanvas is a TOnPrepareCanvasEvent property with the event handler signalled to configure the control Canvas to draw a cell at specified coordinates using a specific state. OnPrepareCanvas is signalled (when assigned) from the DoPrepareCanvas method.

OnPrepareCanvas allows the Pen, Brush, Font, and Color defaults assigned in PrepareCanvas to be overridden for a specified column and row to use a specific TGridDrawState value. It offers the last chance to change the appearance of a cell before it is drawn in the DrawCell or ShowCellHintWindow methods.

Use OnDrawCell (implemented in the TCustomDrawGrid descendant) to override the actions performed in the DefaultDrawCell method when DefaultDrawing is enabled.

Event handler signalled to draw a cell in the grid control.

OnDrawCell is a TOnDrawCell property with the event handler signalled to render a cell in the grid control. Parameters passed to the event handler identify the column and row numbers for the cell, the drawing rectangle, and the grid draw state for the cell.

OnDrawCell can be used to perform drawing operations which supplement or override the default drawing mechanism in the grid control. When DefaultDrawing property is True, the DefaultDrawCell method is called to render the cell background, state, text and focus in the default manner. Use OnDrawCell to perform drawing actions which differ from the default for the specified cell.

OnDrawCell can be used to render all aspects of a cell when DefaultDrawing is set to False. In this situation, the event handler must handle rendering the background, state, text, and focus for the cell.

OnDrawCell is signalled (when assigned) from the DrawCell method at run-time. It is not signalled at design-time. OnDrawCell occurs after the canvas has been configured using PrepareCanvas, and after DefaultDrawCell has been called (when DefaultDrawing is True).

Event handler signalled when the button in a cell Editor is clicked. Deprecated.

Deprecated. Use OnButtonClick instead.

Event handler signalled when a button-style cell Editor control is clicked.

OnButtonClick is a TOnSelectEvent property with the event handler signalled when the button for a button-style Editor control is clicked. It allows the application to perform actions needed when a mouse up event occurs for a cell using the editor type.

OnButtonClick is signalled (when assigned) from the DoEditButtonClick method. An application must implement and assign a handler routine using the signature in TOnSelectEvent to respond to the event notification. Arguments passed to the event handler include the current grid control, and the Column and Row numbers where the click event occurred.

OnButtonClick is not signalled for mouse click events that occur in the header zone for a column.

OnButtonClick is the replacement for the deprecated OnEditButtonClick event handler.

Event handler signalled when an item is selected from a pick list-style Editor control.

OnPickListSelect is a TNotifyEvent property with the event handler signalled when a value is selected from a pick list-style Editor control. It is signalled (when assigned) from the PickListItemSelected method, and occurs after the editor applies the modified value to the cell.

OnPickListSelect can be used to perform actions needed when the cell value is changed as a result of the pick-list selection in the editor. An application must implement and assign an object procedure to the handler to respond to the event notification.

TNotifyEvent
Event handler signalled when an area is selected in the grid control.

The Col and Row parameters contain the column and the row of the highlighted cell.

Application developers can use the OnSelection and OnBeforeSelection events to react to focus changes.

Event handler signalled to select an Editor control for the current grid cell.

OnSelectEditor is a TSelectEditorEvent property with the event handler signalled to select an editor control for a cell in the grid. Arguments to the event handler contain the column and row numbers for the cell, and a variable parameter used to return the editor control used for the specified cell.

OnSelectEditor is signalled (when assigned) from the SelectEditor method. It is not signalled if EditingAllowed returns False for the selected column in Col. It allows the default cell editor for the column (returned from GetDefaultEditor) to be overridden with a user-determined editor for a specific cell.

Event handler signalled when the top left cell in the visible area of the control is changed.

Signalled (when assigned) from the TopLeftChanged method. It occurs when the origin cell is changed when the grid is scrolled, when the value in AutoFillColumns is changed to True, or when the position for the cell editor is updated.

Event handler signalled to get the user-defined bitmap used for a check box cell.

OnUserCheckboxBitmap is a TUserCheckboxBitmapEvent property with the event handler used to get the user-specified bitmap drawn for check box cell on the control. It is signalled from the GetImageForCheckBox method (when assigned) with the control, column, row, and check box state for the cell. Use the Bitmap argument to return the bitmap image provided in the event handler routine.

Use the OnUserCheckboxImage to retrieve an image list and index position with the graphical representation for a specific check box state.

Event handler signalled to get the user-defined image used for a check box cell.

OnUserCheckboxImage is a TUserCheckBoxImageEvent property with the event handler signalled to get a user-specified image list and index position for a check box cell with a give state. It is signalled from the GetImageForCheckBox method (when assigned) with the control, column, row, and check box state for the cell. Use the ImageList and ImageIndex arguments to return the image and position provided in the event handler routine.

Use the OnUserCheckboxBitmap event handler to get the check box image as a TBitmap type.

Event handler signalled to perform validation for a cell value.

OnValidateEntry is a TValidateEntryEvent property with the event handler signalled to perform validation for cells in the ValidateEntry method. The OldValue argument contains the value validated in the handler routine. Use the NewValue argument to return a modified value from the handler routine.

The handler can raise an Exception if needed. It is caught in the calling routine (ValidateEntry), and forwarded to the HandleException method in the Application singleton.

Updated cell values are not validated if the event handler has not been assigned.

TApplication.HandleException
Flips coordinates for the specified cell rectangle when BiDiMode or RTL alignment is used.

FlipRect causes the control display area in ARect to be aligned to the opposite horizontal edge of the parent control when UseRightToLeftAlignment is enabled. Values in the Left and Right members in ARect are modified to reflect the new position / alignment.

FlipRect calls the BidiFlipRect routine to reposition the control on the parent rectangle.

The return value is a TRect instance with modified Left and Right coordinates for the repositioned control.

No actions are performed in the method when UseRightToLeftAlignment is set to False, and the return value is set to ARect.

BidiFlipRect
TRect instance with the updated display area for the control. Control display area examined and potentially updated in the method. Flips cell coordinates for the specified point on the parent rectangle when BiDiMode or RTL alignment is used. TPoint instance with the updated cell coordinates. TPoint instance where the cell coordinates are represented in the X and Y members. Flips the horizontal position in the client when BiDiMode or RTL alignment is used. Integer value with the adjusted X coordinate. X coordinate examined and recalculated in the method. Gets the hint text for a cell.

OnGetCellHint is a TGetCellHintEvent with the event handler signalled to get the hint text for a cell in the grid control. OnGetCellHint is signalled when goCellHints or goTruncCellHints enumeration values are included in the Options property.

OnGetCellHint is signalled (when assigned) from the GetCellHintText and GetTruncCellHintText methods called when ShowCellHintWindow applies the CellHintPriority for the grid control.

Event handler signalled when an entry in Columns is saved to a configuration file using the SaveContent method.

The APath argument contains the XPath-like notation, including the column identifier, used to access the column definition. For example:

'grid/design/columns/column1'
Event handler signalled when a column is loaded in the LoadColumns method. Constructor for the class instance.

Create is the constructor for TCustomGrid. Create calls the inherited Create method, allocates the lists with columns and rows, initializes many visual properties and options, creates the various cell editors, and loads any bitmaps required for the control.

The inherited method calls SetBounds and VisualChange, so the grid needs to be fully instantiated before it is called.
TCustomControl.Create
Owner of the class instance. Destructor for the class instance.

Destroy is the destructor for TCustomGrid. Destroy frees various resources including editors, columns, rows, fonts, and the internal TGridScroller used in the class instance. It calls the inherited Destroy method prior to exit.

TCustomControl.Destroy
Performs a request to redraw the control.

Invalidate is an overridden method in TCustomGrid. It ensures that the internal update counter is at 0 before forcing the control to be redrawn. No actions are performed in the method if the counter has a non-zero value.

Invalidate calls the inherited method where the paint request is performed when the Handle for the control has been allocated.

Invalidate is called when color, style, or content changes occur in the grid which require the control to be redrawn. For instance:

  • AltColorStartNormal
  • AlternateColor
  • BorderColor
  • Color
  • DefaultDrawing
  • DoOnChangeBounds
  • FadeUnfocusedSelection
  • FixedColor
  • FixedGridLineColor
  • FocusRectVisible
  • Flat
  • GridLineColor
  • GridLineStyle
  • GridLineWidth
  • InvalidateGrid
  • MouseDown
  • Notification
  • SelectedColor
  • Selection
  • TitleStyle
  • VisualChange
  • UseXORFeatures
TWinControl.Invalidate
Signals the OnEditingDone event handler.

EditingDone is an overridden method in TCustomGrid called when the user has finished editing using the control. EditingDone ensures that the Editor control is visible before calling the inherited method. The inherited method signals the OnEditingDone event handler (when assigned).

No actions are performed in the method when EditShowing is False.

TControl.EditingDone TControl.OnEditingDone
Adjusts the cell rectangle to account for grid lines drawn around a cell. Cell rectangle adjusted in the method. Automatically adjusts columns sizes to the width of their content. Begins an update to the grid control.

BeginUpdate is a procedure used to start an update to the layout or content in a grid control. BeginUpdate increments an internal member used to prevent nested calls to the method. The protection remains in effect until the EndUpdate method is called. BeginUpdate is used in the implementation of methods that alter the physical appearance of the grid.

The coordinates for the specified cell (ACol, ARow) as a standard rectangle (TRect). TRect instance with the coordinates for the cell. Column number for the cell. Row number for the cell. Determines the grid zone for the specified cell.

CellToGridZone is a TGridZone function used to get the grid zone where the specified cell is located. It is similar in nature to the MouseToGridZone method, but uses grid coordinates instead of mouse coordinates. The return value is one of the TGridZone enumeration values.

gzInvalid
Returned when ACol or ARow contain a negative number.
gzFixedCells
Returned when both ACol and ARow are in the FixedCols and FixedRows for the grid.
gzFixedCol
Returned when ACol is one of the FixedCols for the grid.
gzFixedRow
Returned when ARow is one of the FixedRows for the grid.
gzNormal
Default value returned for a cell that is neither a fixed column nor a fixed row.

CellToGridZone is used in the implementation of methods like MouseUp, CacheMouseDown, Clean, and LoadContent.

TGridZone enumeration value for the cell. Column number examined in the method. Row number examined in the method. Determines if the cell can be selected, or finds a suitable position using auto-advance.

CheckPosition is a method used to determine if the cell in Col and Row can be selected. The SelectCell method is called using values in Col and Row as arguments. If the select is selected, no additional actions are performed in the method.

If the cell cannot be selected because the position is invalid, another cell is sought. The AutoAdvance feature is used to check adjacent cells - first, by moving toward the right then downward, and finally by moving to left then upward. GetDeltaMoveNext and MoveNextSelectable are used to find and select a valid cell position.

In some cases, AutoAdvance and the current cell cannot be used to find an available cell. For this case, a scan of all non-fixed columns an rows is performed until a suitable column and row number are found, and MoveNextSelectable is called. If this too fails, the cell position cannot be determined.

CheckPosition is called from CreateWnd when the window handle is created (or re-created) for the control. It is also called when a new value is assigned to the ColCount or RowCount properties.

Clears the values in the FixedCols and Cols properties.

ClearCols is a Boolean function used to reset values stored in the FixedCols and Cols properties. No actions are performed in the method when the Cols property is empty (Count=0). In this case, the return value is False.

ClearCols ensures that values in EditorMode, ColCount, and FixedCols are reset. For ColCount, this means the length of the internal Integer list is set to 0. The top, left column offset for the visible area in the control is also reset in GCache.

ClearCols is called from the Clear method prior to updating other visuals aspects for the control.

True if the vales are successfully cleared in the method. Clears the cached fixed rows and row count values for the grid control.

ClearRows is a Boolean function used to remove all rows in the grid control. This includes the fixed row for the control. The return value is True if rows are successfully cleared in the method. It is False if the grid is already empty.

ClearRows sets EditorMode to False if a cell editor is visible on the grid control. It sets values in the FixedRows and and RowCount properties to 0 (zero).

It does not change values in the FixedCols or ColCount properties.

True if the rows are cleared in the method. Clears all cells in the grid control.

Clear is a method used to removed the content in all areas of the grid control.

EditorMode is set to False to remove an active Editor for the grid control.

The ClearRows and ClearCols methods are called to reset the values in the Cols, Rows, FixedCols, and FixedRows properties. If either method returns False, the content had already been cleared and no additional actions are performed in the method.

Clears resets the values in internal members that are used to track the top, left visible cell in the control and the current selection range. Hot-lighted (hovered) cells are also reset in the method.

Clear calls VisualChange to update the cached column and row sizes and redraw the control. SizeChanged is also called to notify event handlers of changes to RowCount or ColCount values.

Compatibility: This applies to Lazarus grids only; under Delphi/Kylix a grid cannot be completely emptied.

Use FixedRows, FixedCols, RowCount, and ColCount to specify the number of rows or columns on the grid.

Clears the current range selection(s) and redraws the grid control.

ClearSelections is a method used to remove all selection rectangles in an internal member for the grid control. These are the values stored using AddSelectedRange when multi-selection is enabled in the Options for the control.

ClearSelections calls UpdateSelectionRange to restore the current selection using the values in Col and Row. When goRowSelect has been included in Options, a range selection for all cells in the current row is created. The pivot point for extending the range selection is set to the values in Col and Row.

ClearSelections calls InvalidateGrid to redraw the grid control when another update is not already in progress.

ClearSelections is called when a new value is assigned to the RangeSelectMode property. It is also called from the MouseDown method when a range selection is handled for the non-fixed area in the grid control.

Selects a cell Editor control with the specified style.

EditorByStyle is a TWinControl function used to select the control used as the Editor for a cell using the style in the Style argument.

Style contains a value from the TColumnButtonStyle enumeration, and determines which of the internal pre-allocated editors is used in the return value. Some of the values in Style do not require an editor control, like: cbsNone, cbsCheckboxColumn, and cbsButtonColumn. For these values, the return value is always Nil.

EditorByStyle is called from the GetDefaultEditor method when the grid allows editing (goEditing in Options) and the Column collection has been enabled in the control.

Cell editor for the specified style, or Nil when an editor control is not used for the style. Editor style which determines the editor control selected in the method. Implements the OnKeyDown event handler for the cell editor.

EditorKeydown is assigned as the OnKeyDown event handler in the Editor control when it is configure and assigned to the Editor property. EditorKeydown calls the KeyDown method to apply the Key and Shift arguments.

TWinControl.OnKeyDown
Object (TCustomGrid) for the event notification. Key examined in the method. Shift / Ctrl / Alt modifier for the Key. Implements the OnKeyPress event handler for the cell editor.

EditorKeyPress is assigned as the OnKeyPress event handler when in the Editor control when it is configured and stored in the Editor property. EditorKeyPress calls the KeyPress method to apply the value in Key to the grid control.

A value not handled in KeyPress is checked for a control or UTF-8-encoded character value. When found, the following actions are performed:

^M (Enter or Shift+Enter)
Moves to the next (or previous) cell in the AutoAdvance direction, and Resets the Editor control. Key is set to #0.
UTF-8-encoded characters
Calls EditorCanAcceptKey and EditorIsReadOnly. If Key cannot be handled, it is set to #0. Otherwise, it is retained and passed as an editor key press.
Object (TCustomGrid) for the event notification. Key press examined in the method. Implements the UTF-8 key press handler for the editor in the grid control.

EditorUTF8KeyPress is assigned as the OnUTF8KeyPress event handler for the Editor in the grid control. It calls the inherited UTF8KeyPress method, indicating that the value in UTF8Key is targeted at the Editor control for the grid.

Control for the event notification. UTF-8-encoded code point handled in the method. Implements the OnKeyUp event handler for the cell editor. Object for the event notification. Key examined in the method. Shift / Ctrl / Alt modifier for the Key. Updates the grid control when the value in a cell Editor is changed. Column number for the modified cell. Row number for the modified cell. New value for the cell. Finishes an active update to the grid control.

EndUpdate is a method used to complete an update started by calling the BeginUpdate method.

EndUpdate decrements the internal update counter used in the control. When the counter reaches 0, there are no other updates active for the control. If ARefresh is set to True, the VisualChange method is called to update the cached sizes for the control and Invalidate the control display area.

BeginUpdate and EndUpdate are used to implement methods like:

  • Assign
  • AssignTo
  • Sort
  • ScrollToCell
  • DoAutoAdjustLayout
  • Clean
  • LoadFromCSVStream
True causes the grid control to be redrawn using Invalidate. Clears the background for the grid control.

EraseBackground is overridden in TCustomGrid, and has an empty implementation.

Device context for the drawing operation. Adjusts fonts in the control to the specified design-time PixelsPerInch.

FixDesignFontsPPI is an overridden procedure used to adjust the assigned font size for grid columns and their titles to the specified design-time Pixels Per Inch (PPI). This is needed because the display density (PPI) used for fonts is not stored in Form resource (.LFM) files. When the design-time PPI is different than the run-time setting, font scaling issues can occur.

FixDesignFontsPPI restores the design-time font PPI so it can be used in the LCL Scaling mechanism. FixDesignFontsPPI calls the inherited method on entry, and sets the value for the PixelsPerInch property in TitleFont when needed. Column definitions stored in the Columns property are also adjusted (when needed) by calling the FixDesignFontsPPI method for each of the TGridColumn instances in the container.

FixDesignFontsPPI is called when scaling is enabled, and the Form which hosts the control calls its Loaded method during LCL streaming.

Design-time PixelsPerInch needed for fonts in the control. Indicates if the grid is focused or has an active focused cell Editor. Focused in an overridden method in TCustomGrid. It re-implements the method from the ancestor class, and return True if the control or an assigned cell editor for the control has input focus. It does not call the inherited method. True when the grid or the cell Editor has focus. Indicates if multi-select range selection mode is enabled and in use for the grid.

HasMultiSelection is a Boolean function used to determine if multi-select range selection mode is enabled and in use for the grid. The return value is True when Options includes the value goRangeSelect, RangeSelectMode contains rsmMulti, and Selections contains selection cell rectangles.

True when multi-select range selection mode is enabled and in use for the grid. Hides the arrow drawn as the sort indicator for a column.

HideSortArrow is a procedure used to hide the arrow drawn for the sort indicator defined in SortColumn. HideSortArrow sets the value in SortColumn to -1 to indicate that the sort column is not defined, and calls InvalidateGrid to redraw the contents in the grid control.

Invalidates all cells in the specified column, and causes them to be redrawn.

InvalidateCol is a method used to refresh all cells in the column number specified in the ACol argument. InvalidateCol gets a TRect instance with the bounds for cells in the specified column number. It calls the InvalidateRect routine in the LCL interface using the Handle for the control and the display rectangle as arguments.

No actions are performed in the method if a Handle has not been allocated in the widgetset class instance for the control.

InvalidateCol is not used in the current LCL version. Invalidate is called instead.
Column number for the cells invalidated in the method. Renders a cell invalid, and redraws the cell if required.

InvalidateCell is an overloaded method in TCustomGrid used to invalidate the cell at the column and row numbers in ACol and ARow. The Redraw argument is optional, and forces the cell to be re-drawn as soon as it is invalidated. The default value for Redraw is False, and defers the draw operation until the next time the control is updated.

Column number for the cell. Row number for the cell. True to redraw the cell immediately, False to defer until the next update for the control. Invalidates cells starting at the specified column number; all rows from the start position are affected.

Calls the InvalidateRect routine which causes the cells to be re-drawn. No actions are performed in the method if a Handle has not been allocated for the control.

Initial column number updated in the method. Invalidates the client area for the grid control.

Calls the Invalidate method when no other updates are active for the control.

Invalidates a focused or highlighted cell or row.

InvalidateFocused uses cached grid data in GCache to determine whether the grid control has valid columns and rows. No actions are performed in the method when columns and rows are not present in the cached grid information.

The values in Options are used to determine whether row select or row highlighting are enabled for the control. If either is present in Options, the InvalidateRow method is called for the current Row number. If neither option is used, the InvalidateCell method is called for the current cell in Col and Row.

InvalidateFocused is called from methods that respond to focus changes involving the grid control, including: WMKillFocus, WMSetFocus, DoEnter, and DoExit.

Invalidates a cell range in the grid and causes it to be redrawn. TRect with the range of cells affected in the method. Invalidates the drawing rectangle for the specified row number. Row number affected in the method. Determines whether the specified cell is visible.

IsCellVisible is a Boolean function which indicates whether the cell specified by ACol and ARow is in the visible area for the grid control. IsCellVisible uses the internal cached grid information to determine if the cell is within the cached visible coordinates for the control.

IsCellVisible is used in methods like DrawRow, DoEnter, and InvalidateCell.

Use IsFixedCellVisible to determine whether a specific fixed cell is within the visible area for the control.

True if the cell is in the visible area for the grid control. Column number for the cell. Row number for the cell. Determines if the specified cell is a visible fixed header cell in the grid. True if the specified cell is both fixed and visible in the control. Column number for the cell. Row number for the cell. Loads grid data from a file with the specified file name.

FileName contains name of the file with the content loaded in the method, and may included a fully qualified path. An Exception is raised with the message in rsGridFileDoesNotExist if a file with the specified path and name is not found.

LoadFromFile creates a temporary TXMLConfig instance that is used load the content from the specified file. The private LoadSub method is called using the configuration file instance to read the content in the file, and may raise an exception if the XML content does not have a valid version element.

LoadFromFile reverses the actions performed in the SaveToFile method. Please note that the SaveOptions property determines the information available to be loaded from the file.

Use LoadFromStream to read the content in the grid from a TStream instance.

TXMLConfig
Name of the file with the content loaded in the method. Loads grid data from the specified stream.

AStream is the TStream instance with the content loaded in the method. The stream must be positioned at the location where the information for the grid begins. The stream position is not changed after its content has been loaded.

LoadFromStream creates a temporary TXMLConfig instance that is used load the content from the specified stream. The private LoadSub method is called using the configuration file instance to read the content in the file, and may raise an exception if the XML content does not have a valid version element.

LoadFromStream reverses the actions performed in the SaveToStream method. Please note that the SaveOptions property determines the information available to be loaded from the stream.

Use LoadFromFile to read the content in the grid from a file on the local file system.

TXMLConfig
TStream instance with values loaded in the method. Gets the cell coordinates for the specified mouse pointer position.

MouseCoord is TGridCoord function used to get the coordinates for the mouse pointer as cell coordinates. It calls the MouseToCell method to get the TGridCoord (an alias to TPoint) instance used in the return value.

TGridCood instance with the cell coordinates for the mouse pointer. Horizontal screen coordinate for the mouse pointer. Vertical screen coordinate for the mouse pointer. Converts the specified mouse screen coordinates to cell coordinates.

MouseToCell is an overloaded method in TCustomGrid used to convert screen coordinates for the mouse pointer to cell coordinates. One variant returns the cell coordinates as a TGridCoord (an alias for TPoint) instance. The other variant returns the cell coordinates as Integer output parameters. MouseToCell calls the OffsetToColRow method to get the cell coordinates.

ACol and ARow arguments were changed to output parameters in LCL version 2.1 (revision 65087).
TPoint instance with the grid coordinates for the cell. TPoint instance with the mouse coordinates converted in the method. Horizontal coordinate for the mouse. Vertical coordinate for the mouse. Column number for the mouse position. Row number for the mouse position. Converts mouse coordinates to logical cell coordinates on the grid.

MouseToLogCell is a TPoint function used to convert physical mouse coordinates, represented using the X and Y members in Mouse, to logical cell coordinates for the grid control. Logical cell coordinates are relative to the origin cell displayed as the upper-left non-fixed cell on the grid control.

MouseToGridZone is used to determine where the mouse coordinates are located on the grid control. When the mouse coordinates are located in the non-fixed cells (grid zone is gzNormal), the value from MouseToCell is used as the return value.

For grid zones (like gzFixedRows, gzFixedCols, or gzFixedCells), the cell coordinates in the return value are changed to the last fixed column and/or row number(s) as needed. If the mouse coordinates are in one of several fixed columns or rows, the last column or row is always used in the return value.

MouseToLogCell is used in the MouseMove method when the active cell selection has been changed using the mouse.

TPoint instance with the logical cell coordinates in its X and Y members. TPoint instance with the physical mouse coordinates in its X and Y members. Converts the specified coordinates for the mouse pointer to the grid zone where they are located.

MouseToGridZone is a TGridZone function used to get the grid zone where the specified mouse pointer coordinates are located. The X and Y arguments contain the screen coordinates where the mouse pointer is located.

The return value is a TGridZone enumeration value determine by comparing the screen coordinates to the cached sizes and offsets for the grid control. The screen coordinates are converted to cell coordinates when available, and used to the determine the return value.

gzInvalid
X and Y are located on the border or in a area not used for cells in the client area for the control.
gzFixedCells
X and Y are located in the fixed header cell (column 0) on the control.
gzFixedRows
X and Y are located in a fixed header cell for a row on the control.
gzFixedCols
X and Y are located in a fixed header cell for a column on the control.
gzNormal
X and Y are located in a non-fixed cell in the display area for the control.
Grid zone where the specified mouse pointer coordinates are located. Horizontal screen coordinate for the mouse pointer. Vertical screen coordinate for the mouse pointer. Saves grid information to a file with the specified name.

SaveToFile is a method used to store information from a grid control the file name specified in the FileName argument. FileName can include a fully-qualified path to the file. If the file already exists on the local file system, it is deleted and re-created before writing values.

SaveToFile creates a temporary TXMLConfig instance that is used to write XML values to the specified file, and may include information about the text, layout, cell display settings, grid options, and range selections for the control.

SaveToFile calls the SaveContent method to write the needed values to the XML configuration file. Please note that the SaveOptions property determines the information stored in the method.

Use LoadFromFile to load settings and content from the XML file into the grid control.

TXmlConfig
File name where the grid information is stored. Saves grid information to the specified stream.

SaveToStream is a method used to store information from the grid control to the TStream instance specified in AStream. SaveToStream creates a TXMLConfig class instance that is used to capture the layout, cell display settings, grid options, and range selections for the control.

SaveToStream calls the SaveContent method to generate the XML content for the grid control. The XML content is written to AStream using the WriteToStream method in TXMLConfig.

Use LoadFromStream to read the grid information stored in the stream.

TXMLConfig.WriteToStream
TStream instance where grid information is stored. Resizes fonts using a target PPI and a scaling factor.

ScaleFontsPPI is an overridden procedure used to resize fonts in the control to the specified display density (Pixels per Inch) using the scaling factor in AProportion. This occurs when the run-time PPI setting for a font differs from the design-time value stored in the component resource.

ScaleFontsPPI is overridden to apply the scaling factor to the Font and TitleFont for the control, and any fonts assignments in the Columns collection. The inherited DoScaleFontsPPI method is called to apply the scaling factor to the TFont instance passed as an argument.

TControl.Font TControl.ScaleFontsPPI
New PPI setting for the scaled font sizes. Scaling factor applied to the font sizes. Gives focus to the grid control.

SetFocus is an overridden procedure used to make the grid control the currently focused control. SetFocus ensures that pending Tab key navigation for an active cell editor is handled properly. If an Editor is both available and visible, it calls its SetFocus method. Otherwise, the grid control becomes the focused control.

Current cursor state for the grid control.

CursorState is a read-only TGridCursorState property which contains the current cursor state for the grid control. The value in CursorState is updated when methods are called which perform resizing or moving/dragging for columns and rows.

Use the ColRowDraggingCursor, ColSizingCursor, or RowSizingCursor properties to read or write the cursor shapes used for the corresponding actions.

Use RestoreCursor to set the cursor state to its default value (gcsDefault).

Provides indexed access to TGridRect values in the currently selected range.

SelectedRange is a read-only indexed TGridRect property used to get the cell rectangles in Selections for the grid control. SelectedRange is applicable when multi-select range mode has been enabled in the RangeSelectMode property. Otherwise, the current cell selection at Col and Row is returned as the selected range value.

Use SelectedRangeCount to get the number TGridRect instances in SelectedRange.

Use AddSelectedRange to add the current cell selection to the multi-select range in Selections.

Use ClearSelections to remove the cell rectangles stored in Selections.

Number of cell rectangles in the selected range for the grid.

SelectedRangeCount is a read-only Integer property with the number of selected cell rectangles currently selected in the cells for the control. The property value contains the length of the internal TGridRectArray maintained in the control + 1 (for the current selected cell not already in the array).

Use SelectedRange to access the selection rectangles by the ordinal position in the the internal TGridRectArray instance.

Use AddSelectedRange to add a selection rectangle when RangeSelectMode is set to rsMulti.

Use ClearSelections to remove all selection rectangles and redraw the grid control.

Controls the order used for the sort column (ascending or descending).

SortOrder is a TSortOrder property which indicates the sort order used for the column specified in SortColumn. It is used in the DoCompareCells method to determine the order for values during the comparison.

SortOrder is used in the HeaderClick method to set or invert the ordering when the column header is clicked. It is also used to determine the image displayed in the column heading for the sort column.

The default value for the property is soAscending.

Column number used to sort the rows in the grid.

SortColumn is a read-only Integer that contains the column position used to sort content in the rows for the grid. SortColumn is used in the HeaderClick method to determine if the click occurred on the fixed header cell represented by the property. It is also used in the DrawColumnTitleImage method if the header cell needs to render an image representing the current sort order.

Indicates if keyboard navigation to/from the control is enabled using the Tab or Shift+Tab keys.

The default value for TabStop is True in TCustomGrid, and allows the control to appear in the TabOrder for a Parent form. When goTabs is enabled in Options, Tab and Shift+Tab cannot be used to exit the control.

TWinControl.TabStop TWinControl.TabOrder
Handles IME Composition start messages.

Defined for Windows platforms only.

Record with the arguments for the WM_IME_STARTCOMPOSITION message. Handles IME Composition messages.

Defined for Windows platforms only.

Record with the arguments for the WM_IME_COMPOSITION message. Handles the WM_IME_ENDCOMPOSITION message.

Handles the Input Method Editor API WM_IME_ENDCOMPOSITION message.

Dispatches the message specified in Msg in the current visible and active Editor for the control. Defined for the Windows platform only.

Message handled in the method. Specifies an event handler used to get edit values or masks in a grid.

TGetEditEvent is an object procedure type used for event handlers which get edit values or masks in a grid control. TGetEditEvent is the type used for the OnGetEditMask and OnGetEditText event handlers in TCustomDrawGrid.

Object for the event notification. Column number for the notification. Row number for the notification. Value returned from the event handler. Specifies an event handler used to set the value for edit text in a grid.

TSetEditEvent is an object procedure type used to implement event handlers which set the edit value for a cell in a grid control. TSetEditEvent is the type used for the OnSetEditText property in TCustomDrawGrid.

Object for the event notification. Column number for the notification. Row number for the notification. Value applied to the specified cell in the event handler. Specifies an event handler signalled to get the state for a check box cell in a grid. Object for the event notification. Column number for the cell. Row number for the cell. Checkbox state retrieved for the cell. Specifies an event handler signalled to set the state for a check box cell in a grid.

TSetCheckboxStateEvent is an object procedure type which specifies an event handler signalled to set the state for a check box cell in a grid control. TSetCheckboxStateEvent is the type used to implement the OnSetCheckboxState property in TCustomDrawGrid.

See TGetCheckboxStateEvent for the event handler signalled to get the value for a check box cell in a grid control.

Object for the event notification. Column number for the modified cell. Row number for the modified cell. New check box state for the cell. The base class for a custom-drawn grid control.

TCustomDrawGrid is a TCustomGrid descendant used as the base class for custom-drawn grids including TDrawGrid and TStringGrid. Applications should not create instance of TCustomDrawGrid; use one of the descendent classes like TDrawGrid or TStringGrid.

TCustomDrawGrid provides overridden methods needed to work with cells using the TVirtualGrid class instance in the Grid property. It displays information as a matrix of rows and columns, but unlike TStringGrid, it does not rely on Cells which contain string values. Instead, a container is used to store the data displayed and maintained using the draw grid control. Information entered in a cell editor must update container items to reflect the changes in the grid.

The OnDrawCell event handler is provided to render the cell content in the grid, and can be used to render images or directly access the Canvas for the control. Default cell drawing logic is also implemented using the properties and methods from the ancestor class, and may be accessed from within the OnDrawCell event handler.

Other event handlers can be used to perform actions needed when a column or row value is accessed in the control. For instance: OnSelection, OnSelectCell, OnGetEditText, OnSetEditText, et. al.

Additional information about grid usage is available on the Lazarus wiki in the following pages:

  • Grids Reference Page
  • TDrawGrid
  • TStringGrid
Determines if the cell is valid and enabled, and uses the check box button style. True when the specified cell is valid, enabled, and uses the check box button style. Column number for the cell. Row number for the cell. Draws a cell value using the bitmaps for the check box button style. Column number for the cell. Row number for the cell. Rectangle with the bounds for the cell. Posts a grid message to get the value from the Editor control in a cell. Value from the Editor control. Column number for the cell. Row number for the cell. Contains the virtual grid for the control. Performs actions to handle a mouse click in the specified cell.

CellClick is an overridden method used to handle a mouse click in the cell specified by the values in ACol and ARow. Button indicates the mouse button pressed for the click notification.

CellClick ensures that a left mouse button click causes the cell value in a column using the check box button style to be toggled. When Button contains mbLeft, the column is examined to determine if it uses the check box button style. When both conditions are met, the ToggleCheckbox method is called to update the cell value and display the correct bitmap for the check box state.

CellClick does not occur for a cell that is a fixed header for the column or the row.

CellClick is called from the MouseUp method when a mouse click occurs in a cell that has already been selected, or when AutoEdit has been enabled in the grid Options.

Column number for the cell. Row number for the cell. Mouse button for the click notification. Performs actions when a column or a row is deleted from the control.

ColRowDeleted is an overridden method used to remove the specified column or row, and perform a notification for the change.

IsColumn indicates whether a column or a row is affected in the method. When set to True, a column is removed. Otherwise, a row is removed.

Index contains the column or row number removed in the method.

ColRowDeleted calls the DeleteColRow method in Grid to remove the pointers in the virtual grid for the column or row. NotifyColRowChange is called to perform a notification for the action by signalling the OnColRowDeleted event handler (when assigned).

ColRowDeleted in called from the DoOPDeleteColRow method (in the ancestor class) after removing the column or row in Index from the internal list of column widths, and updating the cached grid information in GCache.

True when a column is affected in the method. False when a row is affected. Ordinal position for the column or row deleted in the method. Performs actions needed when column or row data at the specified positions are exchanged in the grid control.

ColRowExchanged is overridden in TCustomDrawGrid and implements the method defined in the ancestor class. It is used to perform actions needed when column or row values are exchanged (swapped) in the grid control.

IsColumn indicates whether columns or rows are affected in the method. When set to True, column values at the specified positions are exchanged. When set to False, row values are exchanged.

If the Columns property has not been enabled, ColRowExchanged calls the ExchangeColRow method in the internal TVirtualGrid instance for the control.

ColRowExchanged signals the OnColRowExchanged event handler (when assigned).

ColRowExchanged is called from the DoOPExchangeColRow method in the ancestor class.

TCustomGrid.ColRowExchanged TCustomGrid.DoOPExchangeColRow
True if column values are affected. False if row values are affected. Position for the first column or row swapped in the method. Position for the other column or row swapped in the method. Performs actions needed when a column or row is inserted at the specified position in the grid control.

ColRowInserted is overridden in TCustomDrawGrid, and implements the method introduced in the ancestor class. It is used to perform actions needed when column or row values are inserted into the grid control.

IsColumn indicates whether a column or a row is inserted in the method. When set to True, a new column is inserted at the specified position. When set to False, a new row is inserted.

Inserting a column when the Columns property has not been enabled causes the InsertColRow method in the internal TVirtualGrid instance to be called.

The NotifyColRowChange method is called to signal the OnColRowInserted event handler (when assigned).

TCustomGrid.ColRowInserted
True if a column is inserted in the method. False if a row is inserted. Position where the new column or row is inserted in the control. Performs actions when a column or row is moved in the grid.

ColRowMoved is overridden in TCustomDrawGrid to implement the virtual method defined in the ancestor class. It is used to perform actions when a column or a row is moved in the grid control.

ColRowMoved calls the MoveColRow method in the internal virtual grid for the class to change the position for the column or row. The OnColRowMoved event handler is signalled (when assigned) prior to exiting from the method.

ColRowMoved is called from the DoOPMoveColRow method, and occurs after Columns has been updated (when needed and enabled). It occurs before VisualChange is called or the bounds for an editor control are adjusted.

True if a column is moved in the method. False if a row is moved. Position in the grid with the column or row values moved in the method. Position in the grid where the values are stored after they have been moved. Creates and returns the internal virtual grid instance for the control. TVirtualGrid instance created for the control. Draws the the content for the cell specified in the ACol and ARow arguments.

DrawCell is an overridden method in TCustomDrawGrid. It re-implements the method from the ancestor class, and does not call the inherited method. DrawCell is used to draw the content for the cell specified in the ACol and ARow arguments at the position in the ARect parameter. AState contains the grid drawing state applied to the cell.

DrawCell calls PrepareCanvas to initialize the Canvas for the control to the state in AState. This includes setting the default Color, Pen, Brush, and Font attributes used to render the cell content or editor control. The OnPrepareCanvas event handler is signalled to allow the default canvas settings to be overridden on a cell-by-cell basis.

At run-time, DefaultDrawCell is called to perform the default drawing routine for the cell when DefaultDrawing is set to True. DefaultDrawCell is always called at design-time.

At run-time, the OnDrawCell event handler is signalled (when assigned) to render the cell to the Canvas for the control using the grid draw state in the AState argument. When DefaultDrawing is False, OnDrawCell is responsible for all actions performed to draw the cell.

DrawCellGrid is called prior to exit to draw grid lines around the cell (when enabled).

DrawCell is called from the DrawRow method when it renders the visible cells in the grid row.

TCustomControl.Canvas
Column number for the cell rendered in the method. Row number for the cell rendered in the method. Rectangle where the cell is drawn. Grid drawing state for the cell content, editor control, or borders. Draws a cell with auto-numbering.

DrawCellAutonumbering is a method used to draw the text in AValue for the auto-numbered cell at the position in ACol and aRow. DrawCellAutonumbering calls DrawCellText to render the text using the parameter values.

DrawCellAutonumbering is called from the DefaultDrawCell method using the relative non-fixed row number as the text for the cell.

Column number for the cell. Row number for the cell. Rectangle with the bounds for the cell. Text drawn in the cell. Draws the focus rectangle for the control.

DrawFocusRect is an overridden method used to draw the focus rectangle for the specified cell when the grid control or its cell Editor is focused. No actions are performed in the method if DefaultDrawing is set to False, or the grid is not Focused. In addition, the focus rectangle cannot be displayed if goAlwaysShowEditor has been enabled in Options and the Editor is either unassigned (Nil) or not focused.

DrawFocusRect calls CalcFocusRect to apply the cached visual information in GCache for the focused cell or row. This includes adjustments for grid lines when enabled for the control.

When UseXORFeatures is True, the Pen mode in the Canvas is updated to used the XOR drawing operator and the color needed for the control. The Canvas state is restored prior to exiting from the method.

DrawRubberRect is called to draw the rubber band rectangle with the appropriate borders using the FocusColor in the control.

DrawFocusRect is called from the DrawRow method.

Column number for the cell with the focus rectangle. Row number for the cell with the focus rectangle. TRect instance with the bounds for the cell with the focus rectangle. Gets the value for the specified cell.

GetCells is an overridden method in TCustomDrawGrid used to get the String value for the cell specified in the ACol and ARow arguments. It calls the inherited method on entry - which always returns an empty string ('') as the cell value.

When ACol and ARow contain the column and row coordinates for the cell Editor, the value for the cell is retrieved by dispatching a GM_GETVALUE message to the Editor control. This occurs when the control has been assigned and its Visible property is True. The value returned in the grid message is used as the return value for the method.

GetCells is called from EditorShow method.

Value for the specified cell. Column number for the cell value. Row number for the cell value. Gets the check box state for the cell at the specified coordinates.

Signals the OnGetCheckboxState event handler (when assigned) to get the value in AState. Called from ToggleCheckbox and the private DrawCellCheckboxBitmaps method.

Column number for the cell. Row number for the cell. Check box state for the cell. Gets the edit mask for the specified cell.

GetEditMask is an overridden method in TCustomDrawGrid. It re-implements the method from the ancestor class, and does not call the inherited method.

GetEditMask sets the return value to an empty string ('') by default. It signals the OnGetEditMask event handler (when assigned) to get the edit mask used in the editor for the grid cell.

GetEditMask is called from the EditorDoSetValue method in the ancestor class, and occurs when the editor control retrieves and validates the value for the specified cell.

TCustomGrid.GetEditMask TCustomGrid.EditorDoSetValue
Edit mask used for the specified cell. Column for the cell. Row number for the cell. Gets the text displayed in the Editor for the specified cell.

GetEditText is an overridden method used to get the text displayed in the Editor for the specified cell. GetEditText signals the OnGetEditText event handler (when assigned) to get the text displayed in the Editor. The return value can be an empty string ('') when:

  • OnGetEditText is not assigned.
  • The cell at ACol and ARow is empty.
  • Or, a value in ACol or ARow is not valid for the grid.

GetEditText is called from the EditorDoSetValue method when TGridMessages are dispatched to the Editor to set the edit mask and value used in the control.

Text used as the value in the Editor control. Column number for the cell. Row number for the cell. Performs actions when the mouse wheel is scrolled in the grid control.

GridMouseWheel is an overridden method in TCustomDrawGrid used to perform actions when the mouse wheel is scrolled while the grid control has focus. Mouse wheel behavior is determined by the MouseWheelOption property.

When set to mwCursor, the mouse wheel controls the selected row or column in the grid. It increases or decreases the selected row number in the grid by default. Press Ctrl + Mouse Wheel to change the selected column number in the grid.

When set to mwGrid, the mouse wheel scrolls the visible non-fixed columns and rows in the grid control. It scrolls the visible rows up or down by default. Press Ctrl + MouseWheel to scroll the visible columns in the grid control. Mouse wheel movement has no affect when the number of visible columns or rows is not larger than the non-fixed display area for the grid control.

Shift state modifier in effect for the action. Relative change in the current mouse wheel position for the action. Performs actions when a mouse click occurs in a header for a grid column.

HeaderClick is an overridden method ensures that the SortOrder for the grid is toggled when Index contains the SortColumn defined for the grid control. HeaderClick calls the inherited method in TCustomGrid to Sort the non-fixed rows in the grid control.

HeaderClick signals the OnHeaderClick event handler (when assigned) to performed any actions needed after the data has been sorted in the method.

True when a column has been clicked instead of a row. Column or row number for the click notification. Performs actions needed when a column or a row has been resized.

HeaderSized is used to perform actions needed when the header for a column or row has been resized in the grid control.

IsColumn indicates whether the sizing action applies to a column or a row. When set to True, the column header has been resized. When set to False, the row header was resized.

Index indicates the column or row number in the grid where the resizing action occurred.

Calls the inherited method on entry. Signals the OnHeaderSized event handler (when assigned).

HeaderSized is called from methods like MouseUp (when column or row sizing is completed) and DblClick (when column sizing is enabled in the grid Options).

True if a column was resized, False if a Row was resize. Column or row number for the resize operation. Performs actions when resizing a column or row to the specified size.

HeaderSizing is an overridden method used to perform actions when a column or a row is being resized using the mouse. HeaderSizing calls the inherited method on entry, and signals the OnHeaderSizing event handler when assigned.

HeaderSizing is called from the DoColSizing and DoRowSizing methods when GridState has the value gsColSizing or gsRowSizing.

True when the resize action is for a column, or False for a row. Column or row index resized in the method. New size for the column or row. Handles key down events for the grid control.

KeyDown is an overridden method in TCustomDrawGrid, and calls the inherited method on entry. KeyDown ensures that the Space (VK_SPACE) key code is properly applied to the control for a cell using the check box button style.

VK_SPACE (Space)
Calls the ToggleCheckbox method to toggle the checked state for the cell at Col and Row. Key is set to 0 (zero) to indicate that is has been handled in the method.

Called from EditorKeyDown when key down events are enabled in the EditorOptions for the control.

Key code examined in the method. Shift, Alt, Ctrl modifier for the key code. Performs a notification when a column or row has been changed.

NotifyColRowChange is a method used to signal an event handler when a column or a row in the grid has been changed.

WasInsert determines the event handler signalled in the method. When WasInsert is set to True, the OnColRowInserted event handler is signalled (when assigned). When set to False, the OnColRowDeleted event handler is signalled (when assigned).

FromIndex and ToIndex indicate the column(s) or row(s) affected by the change. FromIndex has the column or row number where the action was performed. When a column or row was inserted, ToIndex has the same value as FromIndex. For changes to ColCount or RowCount, FromIndex and ToIndex contain the column or row count prior to and following the change.

NotifyColRowChange is called from methods like ColRowInserted, ColRowDeleted, and SizeChanged.

True if an insert triggered the notification. True if a column was affected by the change. Column or row number affected by the change. Column or row number affected by the change. Determines whether the specified cell can be selected in the grid control.

SelectCell is an overridden Boolean function used to determine whether the cell specified in ACol and ARow can be selected in the grid control. It is used to respond to focus changes for the control.

SelectCell calls the inherited method on entry to get the return value for the method. The return value is True when both ColWidths and RowHeights have positive non-zero values for the column and row numbers where the cell is located.

SelectCell signals the OnSelectCell event handler (when assigned). The event handler can be used to override the return value based on the column and / or row number.

SelectCell is used in the implementation of methods like TryMoveSelection, CheckPosition, SelectEditor, and GetDeltaMoveNext.

True when the specified cell can be selected in the grid. Column number for the cell. Row number for the cell. Sets the value for the Color property.

Calls Invalidate to request the grid control to be redrawn.

New value for the Color property. Sets the value for a check box in the specified cell to a given state.

SetCheckboxState is a method used to set the checked, unchecked, or grayed state for a check box in the cell specified by ACol and ARow. AState contains the state value applied to the cell.

SetCheckboxState signals the OnSetCheckboxState event handler (when assigned) to perform the actions needed to change the value in the cell. If DefaultDrawing is enabled for the control, the InvalidateCell method is called and causes the cell to be redrawn.

No actions are performed in the method when OnSetCheckboxState has not been assigned.

SetCheckboxState is called from the ToggleCheckbox method to apply the new state value for the CheckBox.

Column number for the cell with the CheckBox. Row number for the cell with the CheckBox. State value for the CheckBox. Sets the value used in the cell Editor to the specified text.

SetEditText is an overridden method used to set the the text displayed in the Editor for the cell specified in ACol and ARow.

SetEditText signals the OnSetEditText event handler (when assigned) to get the Value provided to the cell Editor. The inherited method is called to apply the cell value to the editor control.

SetEditText is used in KeyDown when the Escape key (VK_ESCAPE) is not handled by the grid control. It is called from the EditorGetValue method when a visible cell Editor is updated. It is called from EditorTextChanged method when the value in a cell Editor has been altered using the Change or Select methods in the editor control.

Column number for the cell. Row number for the cell. New value for the cell Editor. Performs actions needed when the number or columns or rows has been changed.

SizeChanged is an overridden method in TCustomDrawGrid used to perform actions needed when the number or columns or rows has been changed for the grid control. SizeChanged ensures that the changed values are recorded in the internal virtual grid for the control, and performs a notification for the change.

When OldColCount differs from the value in ColCount, the current ColCount is stored in the virtual grid. NotifyColRowChange is called to generate an insert or a delete notification for the change in ColCount.

When OldRowCount differs from the value in RowCount, the current RowCount is stored in the virtual grid. NotifyColRowChange is called to generate an insert or a delete notification for the change in RowCount.

SizeChanged is called from the AdjustCount and Clear methods.

Previous number of columns. Previous number of rows. Toggles the state for a check box cell between the checked and unchecked values.

ToggleCheckbox is a method used to toggle the state for a check box located in the cell at Col and Row in the grid control.

No actions are performed in the method when Col is not an editable column in the grid. This can occur when goEditing has not been included in the Options for the control. It can also occur if the column definition in Columns has its ReadOnly property set to True.

ToggleCheckbox determines the TCheckboxState value for the cell. The default state is cbGrayed. GetCheckboxState is called to get the current state using the OnGetCheckboxState event handler (when assigned). The value is toggled (cbChecked becomes cbUnchecked, and vice versa). SetCheckboxState is called to apply the toggled value using the OnSetCheckboxState event handler (when assigned), and to redraw the cell.

The OnCheckboxToggled event handler is signalled (when assigned) prior to exiting from the method.

ToggleCheckbox is called from the CellClick method when a left mouse button click occurs in the cell. It is also called from the KeyDown method when the Space (VK_SPACE) key is applied for the cell.

Event handler signalled to get the state for a check box cell.

OnGetCheckboxState is a TGetCheckboxStateEvent property with the event handler signalled to get the state for a check box cell. The ACol and ARow parameters contain the position for the cell. Value contains the TCheckBoxState value for the cell as assigned in the event handler.

OnGetCheckboxState provides the only mechanism to get the state value for a check box cell in TCustomDrawGrid / TDrawGrid. This differs from TCustomStringGrid / TStringGrid, where the TGridColumn instance in Columns can is used (when enabled) to get the checked or unchecked value and determine the state for the cell. This approach can be implemented in the event handler; it is not provided by default.

OnGetCheckboxState is signalled (when assigned) from the GetCheckBoxState method.

Use OnSetCheckboxState to set the state for the check box cell.

Event handler signalled to set the state for a check box cell.

OnSetCheckboxState is a TSetCheckboxStateEvent property with the event handler signalled to set the state for a check box cell. The ACol and ARow parameters contain the position for the cell. Value contains the TCheckBoxState value stored in the cell.

OnSetCheckboxState provides the only mechanism to set the state value for a check box cell in TCustomDrawGrid / TDrawGrid. This differs from TCustomStringGrid / TStringGrid, where the TGridColumn instance in Columns can is used (when enabled) to get the checked or unchecked value and determine the state value stored in the cell. This approach can be implemented in the event handler; it is not provided by default.

OnSetCheckboxState is signalled (when assigned) from the SetCheckBoxState method.

Use OnGetCheckboxState to get the state for the check box cell.

Constructor for the class instance.

Create is the overridden constructor for TCustomDrawGrid. Create allocates the virtual grid (TVirtualGrid) instance used in the control, and calls the inherited constructor prior to exiting from the method.

Owner of the grid control. Destructor for the class instance.

Destroy is the overridden destructor for the class instance. Destroy frees resources allocated to the member used for the internal virtual grid in the control. Destroy calls the inherited destructor prior to exiting from the method.

Deletes a column or a row at the specified position.

DeleteColRow is a method used to delete the column or row at the specified position.

IsColumn determines whether a column or a row is affected in the operation. When set to True, a column is deleted. Otherwise, a row is deleted.

Index contains the column or row number deleted in the method. An exception will be raised if Index contains an invalid value for the ColCount or RowCount in the grid control.

DeleteColRow calls DoOPDeleteColRow with the parameter values to perform the delete operation.

DeleteColRow is used in the implementation of the DeleteCol and DeleteRow methods.

Use InsertColRow to insert a column or row at a given position in the grid. Use MoveColRow to move a column or row to a new position in the grid. Use ExchangeColRow to swap column or row values at the specified positions in the grid.

True to delete a column in the method, False for a row. Column or row number deleted in the method. Deletes the column at the specified position on the grid control.

Calls DeleteColRow to delete the column number specified in Index.

Position for the column removed in the method. Deletes the row at the specified position on the grid control.

Calls DeleteColRow to delete the row number specified in Index.

Position for the row removed in the method. Exchanges column or row values at the specified positions. True when the index positions refer to columns. Position for the first column in the exchange. Position for the second column in the exchange. Inserts a column or a row at the specified position. True when a column should be inserted in the method. Position where the column or row is inserted in the grid. Moves a column or a row from a specified position to a new position in the grid.

Implemented using the DoOPMoveColRow method.

Values in FromIndex and ToIndex must be valid column or row numbers for the control. An EGridException is raised if either value is not valid.

No actions are performed in the method if FromIndex and ToIndex have the same value.

No actions are performed in the method if IsColumn is True and columns are locked using the GridFlags. This occurs when a column index is being updated in the control.

Calls ColRowMoved to perform a notification when the column or row has been moved.

Calls VisualChange if the Columns collection has not been enabled in the control, or when IsColumn is False.

Updates the bounds for the cell editor when it is located in a column or row affected in the method.

Updates the value in SortColumn if it is affected in the method.

True when a column is moved in the method. Position for the column or row moved in the moved. New position where the column or row is stored. Sorts the data in a column or row using the specified positions. True when values in a column are sorted, False to sort values in a row. Column or row number sorted in the method. Starting position sorted in the column or row. Ending position sorted in the column or row. The default method used to draw the cell at the given position using a specific state.

DefaultDrawCell is a method which provides the default drawing routine for the cell at the position specified in ACol and ARow. The bounds for the cell are provided in the ARect parameter. AState contains the drawing state for the cell.

DefaultDrawCell handles the following drawing tasks when needed for the specified cell:

  • Draws fixed cells using the TitleStyle for the control. Calls DrawThemedCell when TitleStyle is set to tsNative. Otherwise, DrawFillRect is used.
  • Draws the bitmap needed for a cell using the check box button style. Calls DrawCellCheckboxBitmaps to render the bitmap for the check box control.
  • Draws a cell using the Button style. Calls DrawButtonCell to render the button in the required state.
  • Draws auto-numbered fixed row headers when enabled in the Options for the control. Calls DrawCellAutonumbering to render the relative non-fixed row number.
  • Draws the text displayed in the cell. Calls DrawColumnText when the cell is a fixed column header. Otherwise, the DrawTextInCell method is used.

DefaultDrawCell is called from the DrawCell method. It is used when the DefaultDrawing property is set to True, and occurs prior to signalling the OnDrawCell event handler (when assigned). It is always called when OnDrawCell has not been assigned.

Column number for the cell. Row number for the cell. Rectangle with the bounds for the cell. Drawing state for the cell. Event handler signalled when a grid column or row is deleted.

Signalled from the NotifyColRowChange method (when assigned). It occurs after the column or row has been removed from the internal virtual grid for the class instance.

Event handler signalled when a column or row has been exchanged with another.

Signalled from the ColRowExchanged method (when assigned). It occurs after the columns or rows have been swapped using the internal virtual grid for the class instance.

Event handler signalled when a column or row is inserted into the grid.

Signalled from the NotifyColRowChange method (when assigned) when an insert notification is performed. It occurs after the column or row has been inserted by calling the InsertColRow method in the internal virtual grid for the class instance.

Event handler signalled when a column or row in the grid is moved.

Signalled from the ColRowMoved method (when assigned). It occurs after the column or row value have been moved using the MoveColRow method in the internal virtual grid for the class instance.

Event handler signalled to compare the content in cells

Signalled from the DoCompareCells method (when assigned) when the Sort method is executed for the grid control. It occurs before the DoOPExchangeColRow method has been called yo change the order for the Columns on the grid control.

Event handler signalled to get the edit mask used for a grid cell.

Signalled from the GetEditMask method (when assigned). It provides the value passed in a GM_SETMASK message to the cell Editor in the control when the EditorGetValue method is executed.

Event handler signalled to get the value for a cell editor in the grid.

OnGetEditText is a TGetEditEvent property with the event handler signalled to get the value for a cell editor on the grid control. It is signalled (when assigned) from the GetEditText method, and provides the value dispatched in a GM_SETVALUE message to the Editor control.

Event handler signalled when the fixed header for a column or row is clicked.

Signalled from the HeaderClick method (when assigned). It occurs when a mouse up event or column accelerator key is handled for a header cell on the grid control. It occurs after the SortOrder and SortColumn have been updated and the Sort method has been called when ColumnClickSorts is enabled.

Event handler signalled when a column or row header has been resized.

OnHeaderSized is a THdrEvent property with the event handler signalled when a column or a row on the grid has been resized. OnHeaderSized is signalled (when assigned) from the HeaderSized method. It occurs when a mouse up event is handled while column or row sizing is active. It occurs after ResizeColumn or ResizeRow has been called, and the scroll bars have been adjusted for the control.

Event handler signalled when a column or row header sizing action is started.

OnHeaderSizing is a THeaderSizingEvent property with the event handler signalled when a column or row header sizing action is started. It is signalled (when assigned) from the HeaderSizing method, and occurs when MouseMove events are handled when the internal grid state is set to gsColSizing or gsRowSizing.

Event handler signalled when a grid cell is selected.

OnSelectCell is a TOnSelectCellEvent property with the event handler signalled when a cell is selected in the grid control. OnSelectCell is signalled from the SelectCell method. It occurs when a change in the current cell selection has been or is about to be performed, or when a cell editor is selected for the grid control. The CanSelect argument allows the event handler to control whether the cell at ACol and ARow can be selected.

Event handler signalled when the text in the cell Editor is assigned.

OnSetEditText is a TSetEditEvent property with the event handler signalled when the text in the cell Editor is assigned. OnSetEditText is signalled from the SetEditText method immediately before calling the inherited SetEditText method. The Sender argument is the current grid instance for the notification.

Implements a custom-drawn grid control.

TDrawGrid is a TCustomDrawGrid descendant which implements a custom-drawn grid control. The control represents it information as a matrix of rows and columns, and is oriented towards rendering both graphical information and textual content.

The OnDrawCell event handler is used to render the cell content in the grid, and can be used to render images or directly access the Canvas for the control. Default cell drawing logic is also implemented using the properties and methods from the ancestor class.

TDrawGrid sets the visibility for properties introduced in the TCustomDrawGrid ancestor, and does not provide any new functionality.

Additional information about grid usage is available on the Lazarus wiki in the following pages:

  • Grids Reference Page
  • TDrawGrid
  • TStringGrid
Uses the Color from the Parent control, when enabled.

ParentColor determines if the control should use the Color from the Parent control, when enabled. The default value for the property is False in TDrawGrid.

When this property is True, all changes to the Color of the parent will also be applied to the Color of the control, ensuring that they both contain same value. If the Color of the control is changed by the application, then ParentColor will be automatically set to False.

Using ParentColor when the Color value is clDefault can cause problems in resolving the actual color value. To obtain the Color property of a control while taking into account clDefault and ParentColor, use the GetColorResolvingParent method. This method might return a non-RGB color, but will never return clDefault. To obtain a purely RGB result use the GetRGBColorResolvingParent method.

TControl.ParentColor TControl.Color TControl.GetColorResolvingParent TControl.GetRGBColorResolvingParent
Represents strings used as the cell values in TCustomStringGrid / TStringGrid.

TStringGridStrings is a TStrings descendant that implements the string container used to populate the cells in a TStringGrid instance. A temporary TStringGridStrings instance is created and used to store a new value assigned to the Cols or Rows property in TStringGrid.

Converts an index position to line and column numbers for the Cells in a grid.

ConvertIndexLineCol is a Boolean function used to convert the specified Index position to line and column numbers for the Cells in the grid control. If the class instance was created to represent values in a single column, Index represents a row number. Otherwise, it represents a column number.

The Line and Col parameters are variable arguments used to return the line number and column number represented by Index to the caller. For row values in a single column, Line is set to the row number passed to the constructor and Col is set to the value in Index. For column values in a single row, Line is set to the value in Index and Col is set to the column number passed to the constructor.

The return value is set to True when Index is valid for the column or row, and the values in Line and Col arguments have been updated. Values in Line and Col are not maintained when the return value is False.

True when Index is valid, and both Line and Col have been updated. Ordinal position in the column or row values. Returns the line (row) number for requested Index. Returns the column number for requested Index. Gets the string at the specified index position. TStrings.Strings String value at the specified position. Ordinal position for the string. Gets the value for the Count property. TStrings.Count Value for the Count property. Gets the value for the indexed Objects property. TStrings.Objects Value for the property. Ordinal position for the property value. Sets the value for the indexed Strings property. TStrings.Strings Ordinal position for the property value. New value for the indexed property. Sets the value for the indexed Objects property. TStrings.Objects Ordinal position for the indexed property value. New value for the indexed property. Constructor for the class instance.

Create is the constructor for the class instance, and calls the inherited constructor on entry. Create stores parameter values to the members used for the associated grid and the map used in the class instance.

Grid for the string values. Map with the owner for the class instance. True when the values represent a column for the associated grid; False for a row. Column or row number in the grid for the data values. Destructor for the class instance. TStrings.Destroy Adds the specified string to the class instance. TStrings.Add TStrings.Strings TStrings.Values Ordinal position in the class instance where the value was stored. String value added in the method. Stores property values from Source into the current class instance. TStrings.Assign Persistent object with the property values copied in the method. Removes all values for the column or row represented by the class instance. TStrings.Clear Deletes a value stored in the class instance.

Delete is overridden to prevent removing entries in the Strings property. It always raises an EGridException exception.

Raises an EGridException exception with the message 'Cannot delete value.' TStrings.Delete
Ordinal position for the value to be removed; not used in the method. Inserts a value in the class instance.

Insert is an overridden method in TStringGridStrings. It prevents an insert using the class instance, and raises an EGridException exception with the message 'Cannot insert value'.

TStrings.Insert
Ordinal position where the string value would be inserted. String value that would be inserted in the method. The base class for TStringGrid.

TCustomStringGrid is a TCustomDrawGrid descendant which implements the base class for TStringGrid.

TCustomStringGrid provides the familiar tabular format used in grid controls, and is designed for use with string content stored in its cells. Internally, columns and rows in the class are mapped to TStringGridStrings instances used to store the values in the grid control. TCustomStringGrid also allows a TObject instance to be stored for each cell in the grid using the Objects property.

Additional information about grid usage is available on the Lazarus wiki in the following pages:

  • Grids Reference Page
  • TDrawGrid
  • TStringGrid
Gets the values in the specified column number as a TStrings instance.

GetCols is the read access specifier for the indexed Cols property.

TStrings with row values for the specified column number. Column number retrieved in the method. Gets the value for the indexed Objects property. Value for the indexed property. Column number for the object. Row number for the object. Gets the value for the indexed Rows property. Value for the property. Ordinal position for the requested row. Frees the TStringGridStrings instances in the specified Map. TMap instance examined and updated in the method. Gets the values for the specified column or row number.

IsCols indicates whether column or row values are accessed and returned in the method. When set to True, values for each of the rows in the specified column number are returned as the result. Otherwise, values for each of the columns in the specified row number are returned as the result.

Index is the ordinal position in the grid with the column or row values returned in the method.

AMap is a TMap instance with the values returned in the TStrings result for the function. If a value has not been assigned to AMap, a new TMap instance is created to store the TStringGridStrings instance used to represent the specified column or row number.

The HasID method in the map is called to check for an existing node in the map. The GetData method in the map is called to store the map data in the return value. If the map does not contain the value in Index, a new TStringGridStrings instance is created for the map, and assigned as the return value.

MapGetColsRows is used to implement the read access specifiers for the Cols and Rows properties.

TMap
TStrings instance with the values in the specified column or row. True when columns are returned, False for rows. Column or row number for the values retrieved in the method. Map instance used (or created) in the method. Reads string values for the Cells property using a TReader instance. TReader instance used to read values during LCL streaming. Sets the value for the indexed Cols property. Ordinal position for the affected column New value for the indexed property. Sets the value for the indexed Objects property. Ordinal position for the column. Ordinal position for the row. New value for the indexed property. Sets the value for the indexed Rows property. Ordinal position for the row affected. New value for the indexed property. Writes the string values in the Cells property using the specified TWriter instance. TWriter instance used to write values to the LCL resource stream for the component. Copies the content from cell(s) in the specified selection rectangle to the clipboard. Only visible cells in the selection rectangle are included in the copied values. Others are quietly discarded. HTML TABLE syntax is used to store the cell values copied in the method. LineEnd and HTML reserved characters are translated into HTML-safe tags or HTML character entities. Cell selection rectangle with values copied in the method. Assigns values from the current class instance to the target class instance. Adjusts the column size for the font, text length, and images used in the specified column.

Adjusts the column specified in ACol to use the width needed for the font and image(s) for the column. No actions are performed in the method when ACol is not a valid column index.

AutoAdjustColumn calculates the width need for the image (if any) used in the column header, and adds the padding specified in the DEFIMAGEPADDING constant. If a sort indicator is used, the same actions are performed for the sort image. The image widths may be scaled to the current display density if the PPI for the control Font differs from the value in TitleImageList.

AutoAdjustColumn visits the rows in the grid to calculate the maximum width required for the text in each. A temporary Canvas instance is used to calculate the width for the text. When Columns has been enabled, fonts assigned to the TGridColumn instance are used. When Columns has not been enabled, TitleFont is used for fixed rows or columns. Otherwise, the Font for the grid is used.

For multi-line columns, the DrawText routine is called to calculate the text rectangle. For single-line columns, the TextExtent method in the canvas is used. Cell padding is added to the calculated column width using the value in varCellPadding. The derived column width is stored in the ColWidths property for the column specified in ACol.

AutoAdjustColumn is called from the DblClick method when column auto-sizing and double click auto-sizing have been enabled in the Options for the grid. It is also called from the AutoAdjustColumns, AutoSizeColumns, and AutoSizeColumn methods.

Column number for values examined in the method. Deprecated in the ancestor class. CalcCellExtent is marked as deprecated in the ancestor class. TCustomGrid.CalcCellExtent Defines non-published properties included in LCL component streaming.

DefineProperties is an overridden method used to define non-published properties which are read and written using LCL component streaming. In TCustomStringGrid, it adds read and write routines for the Cells property to the TFiler instance.

TFIler instance used to read or write values for the class type. Defines the reader and writer for the Cells property in a TFiler instance.

Called from the DefineProperties method.

TFiler instance updated in the method. Performs a comparison between the specified cells in the grid control.

DoCompareCells is an overridden method used to compare cell values in the Sort method. It calls the inherited method when the OnCompareCells event handler has been assigned. The return value from the event handler contains the relative sort order for the compared cells, and uses the following values:

-1
The cell at ACol and ARow occurs comes before the cell at BCol and BRow.
0
The specified cells have the same value.
1
The cell at ACol and ARow occurs comes after the cell at BCol and BRow.

When OnCompareCells is not assigned, the UTF8CompareLatinTextFast routine is called to perform the cell comparison and provide the return value for the method. When SortOrder is set to soDescending, the return value is negated.

UTF8CompareLatinTextFast
Relative sort order for the compared cell values. Column number for the first cell value in the comparison. Row number for the first cell value in the comparison. Column number for the second cell value in the comparison. Row number for the second cell value in the comparison. Performs actions needed when cell values are copied or pasted using the clipboard.

Signals the OnCellProcess event handler when assigned.

Column number for the cell. Row number for the cell. Process performed in the method. Contains the value after performing the specified process. Draws the text and image for a grid column title at the specified cell coordinates.

DrawColumnText is an overridden method used to draw the text and image for a grid column title at the cell coordinates specified in ACol and ARow. When Columns has been enabled, the inherited method is called to draw the image, sort indicator, and text when needed. When Columns has not been enabled, the DrawColumnTitleImage and DrawCellText methods are called to draw the sort indicator and text for the column.

DrawColumnText is called from the DefaultDrawCell method for cells which contain fixed column titles.

Column number for the cell. Row number for the cell. Rectangle with the bounds for the cell. Drawing state for the cell. Draws the text for the specified cell in a given drawing state.

DrawTextInCell is a method used to draw the text for the cell specified in ACol and ARow. It calls the DrawCellText method using the specified arguments.

DrawTextInCell is called from the DefaultDrawCell method.

Column number for the cell. Row number for the cell. Rectangle with the bounds for the cell. Drawing state for the cell. Performs auto-numbering for a cell in the grid.

Renders the row number for non-fixed rows in the grid control. Calls the inherited DrawCellAutoNumbering method when the cell at ACol and ARow contains an empty string ('').

Called from the DefaultDrawCell method when goFixedRowNumbering is included in Options.

Column number for the cell. Row number for the cell. Rectangle where the cell is drawn. Text to display as the auto-numbering value. Gets the value for the indexed Cells property. Value for the indexed Cells property. Column number for the cell. Row number for the cell. Gets the state for a cell displayed as a Checkbox. Column number for the cell. Row number for the cell. Checkbox state derived for the specified cell. Gets the text displayed in the Editor for the specified cell.

GetEditText is an overridden method used to get the text displayed in the Editor for the cell with the specified column and row numbers. GetEditText re-implements the method defined in the ancestor class.

The return value contains the string stored in Cells at the specified column and row numbers.

GetEditText signals the OnGetEditText event handler (when assigned) to validate or modify the return value for the method.

Textual content for the cell at the specified column and row number. Column number for the cell value. Row number for the cell value. Loads configuration settings from the specified XML configuration file.

Loads values for the Cells property when enabled in the configuration file.

Performs actions when LCL component streaming has been completed.

Calls the inherited method on entry, and sets the value for the Modified property to False.

Saves configuration settings from SaveOptions and optionally values from Cells in the specified XML configuration file. Stores the specified Tab-separated values to the Selection in the grid. Text with the tab-separated values stored to the cells in Selection. Sets the value for the current Selection to the specified HTML content.

Extracts text for rows and columns in the grid from the HTML-tagged content in TheHTML. Recognizes and converts the following HTML tags:

  • BR
  • TR
  • TD

Converts HTML numeric character entities to their UTF-8-encoded character equivalent. Unrecognized character entities are converted to a Question Mark character (?).

Calls DoCellProcess to paste the values extracted from the HTML content. The value in TheText is used when TheHTML does not contain valid HTML that can be handled in the method. Cells affected in the method are assigned as the current Selection in the grid control prior to exit.

Called from the DoPasteFromClipboard method when the clipboard supports the HTML format.

HTML stored in the current selection. Textual representation for the HTML content. Sets the value for the indexed Cells property. Column number for the affected cell. Row number for the affected cell. New value for the indexed Cells property. Sets the checked state for a check box in the specified cell. Column number for the cell. Row number for the cell. Checked state for the cell. Locks, updates, and unlocks the editor and cell text at the specified coordinates. Column number for the modified cell. Row number or the modified cell. New value for the modified cell. Indicates whether the content in the grid cells has been changed.

Modified is a Boolean property which indicates whether the cell content in the grid control has been changed. Modified is set to True when the Cells property is updated and the SetCells method is called to apply the new value. This occurs when a cell is edited using a built-in cell editor, or when a value is directly assigned to the Cells property.

Modified is set to False when the control is Loaded using the LCL streaming mechanism.

Methods which use Cells to indirectly assign value(s) also set Modified to True. These include: AssignTo, SelectionSetText, SelectionSetHTML, SetCheckBoxState, SetEditText, LoadContent, Clean, InsertRowWithValues, LoadContent, LoadFromFile, LoadFromStream, LoadFromCSVFile and LoadFromCSVStream.

In contrast, methods which perform row or column operations without changing Cells do not cause the Modified property to be set. These are generally methods from an ancestor class where Modified does not exist, and include: ClearCols, ClearRows, DeleteColRow, DeleteCol, DeleteRow, ExchangeColRow, InsertColRow, MoveColRow, SortColRow, DoOPDeleteColRow, DoOPExchangeColRow, DoOPInsertColRow, and DoOPMoveColRow.

The event handlers signalled from these methods can be used to update the value in Modified, including: OnColRowDeleted, OnColRowExchanged, OnColRowInserted, OnColRowMoved, and OnCompareCells. Or, as an alternative, update Modified from an event handler like OnClick assigned to the control which triggers one of these operations.

Methods which save the grid content do not reset the value in Modified when the operation is completed. These include: SaveContent, SaveToFile, SaveToCSVFile, SaveToStream, and SaveToCSVStream. These actions are triggered by a control in the application, and its OnClick or OnExecute handler can be used to set the value in Modified.

Event handler signalled when copying or pasting content for Cells in the grid.

Allows the textual value for the clipboard operation (not the HTML interchange data) to be changed before it is applied. Signalled from the DoCellProcess method when assigned.

Constructor for the class instance.

Create -is the constructor for TCustomStringGrid. It calls the inherited Create method, and sets default styles, layout and alignment used in the class instance.

Owner of the class instance. Destructor for the class instance.

Destroy is the destructor for TCustomStringGrid. It frees maps of columns and rows, and calls the inherited Destroy method.

Automatically adjusts the width of a column to accommodate the widest text value in the column.

AutoSizeColumn sets the column width to the length of the widest text found in the column specified by ACol.

AutoAdjustColumn is called to determine the width needed for the specified column number. The measurement includes optional title images and sort indicators for column headers, the text displayed for the cells using the Font or TitleFont for the control, and cell padding. Each row is visited to measure the content displayed in the column.

The calculated width is stored in ColWidths at the position in ACol.

Use AutoSizeColumns to calculated the sizes for all Columns on the grid control.

Include goDblClickAutoSize in the Options property to allow columns to be automatically resized when a mouse double Click occurs on the border in a cell header. In other words, when the resize cursor is visible.

Column number resized in the method. Resizes all columns to accommodate the longest text value in each column.

Automatically resizes all columns by adjusting them to fit in the longest text in each column. This is a quick way to perform the AutoAdjustColumn method for every column in the grid.

AutoSizeColumns calls the AutoAdjustColumn method for column numbers in the range 0..ColCount-1. Calculated column widths are stored at the corresponding positions in the ColWidths property.

Use AutoSizeColumn to adjust the width for a single column on the grid control.

Removes cell content which match the specified options.

Cleans all cells in the grid subject to the given CleanOptions, optionally specifying a range of cells or a rectangular region. See for more information.

The cleaning operation does not change the number of rows and columns on the grid control. It replaces the content for the affected cells with empty strings ('').

Some examples:

Clean all cells:

// the same as grid.clean grid.Clean([]);

Clean all non-fixed cells:

text

grid.Clean([gzNormal]);

Clean all cells except fixed grid columns:

// leaves cell content in fixed columns grid.Clean([gzNormal, gzFixedRows]);

Clean non-fixed cells in a rectangular region:

// 4x3 cell area after fixed columns and rows grid.Clean(grid.FixedCols, grid.FixedRows, grid.FixedCols+3, grid.FixedRols+2, [gzNormal])

Use Clear to remove all columns and rows on the grid.

Use ColCount, FixedCols, RowCount, and FixedRows to adjust the number of columns or rows for the specific types.

Set with the grid zones affected in the method. Rectangle with the bounds for the affected cells. Starting column number for the operation. Starting row number for the operation. Ending column number for the operation. Ending row number for the operation. Copies the current Selection range to the clipboard.

CopyToClipboard will copy a range of cells into the clipboard. The cell values are stored in a Tab-delimited format. The cell selection range is based on the optional AUseSelection parameter (which is False by default) and indicates the range is set to the whole grid, including fixed columns and rows. If AUseSelection is True, the range of cells is set to the current values in the property.

TCustomStringGrid provides run-time support for pasting cell values from the clipboard, but is limited to a single selection range. Pasting multi-selections is problematic since the ranges can represent non-adjacent cell areas. For this reason, a PasteFromClipboard method is not implemented in TCustomStringGrid. No actions are performed when Ctrl+V is pressed and HasMultiSelection returns True.
Inserts a row at the specified row position with the specified cell values.

InsertRowWithValues is a method used to insert a row at the position in Index with the cell content in Values.

InsertRowWithValues examines Values to determine whether the grid has a column for each of the string values. When Values has more entries than columns available in ColCount, new columns are added to the grid. When Columns has been Enabled, the Add method in Columns is called to create any missing column definitions. The title for a column added to the collection is set to an empty string (''). When Columns has not been enabled, the value in ColCount is set to the length of the Values array.

InsertRowWithValues calls InsertColRow to increment the row count for the grid, and assigns each String in Values to the corresponding Cells in the grid control.

Use DeleteRow to remove a row at a specific row number in the grid.

Row where the values are inserted. Array with string values inserted in the method. Loads the grid content from the delimited values in AStream.

LoadFromCSVStream is a method used to load content in the grid from comma-separated values stored in the specified stream.

AStream is the TStream instance where the delimited values are stored.

ADelimiter is a character which identifies the delimiter used between column values on a row. Its default value is ',' (Comma) (decimal 44), but can be changed to another character value if needed.

Each row of values is terminated by a Carriage Return (Decimal 13) or Line Feed (Decimal 10) character. CR+LF may also be used. When LoadFromCSVStream encounters either of the characters, it is processed as an end-of-line marker.

UseTitles indicates whether the first row of values in the stream are treated as fixed column titles in the grid. When set to True, each column value is stored as the caption for the corresponding entry in the Columns collection (when enabled). If Columns are not used, the values are stored as cell data in row number 0. When set to False, the first row is treated as cell data. The default value is True.

FromLine indicates the ordinal line number in AStream that is the first row loaded in the method. The default value is 0, and causes stream processing to begin at the first line. When a positive non-zero value is used, the lines are skipped by reading the corresponding number of end-of-line sequences from the stream.

SkipEmptyLines indicates whether blank lines are skipped when the row and column values are loaded in the method. The default value is True, and causes any row with a single empty column value to be skipped.

LoadFromCSVStream calls the LoadFromCSVStream routine in the LCSVUtils unit to load values from the stream. This routine provides support for converting character encodings when needed.

LoadFromCSVStream ensures that the grid control has enough columns to represent the values read from the stream. When Columns is enabled, its Add method is called to create additional columns (when needed). If this occurs on the first line and UseTitles is enabled, cell values are stored as the Title for each of the columns. If Columns is not enabled, the value in ColCount is updated to reflect the number of columns read from the stream.

Please note that updates to the control occur in a BeginUpdate..EndUpdate block. This suppresses redrawing the control until all columns and rows in the stream have been loaded.

Use LoadFromCSVFile to load grid content from a file containing the comma-separated values.

Use SaveToCSVFile or SaveToCSVStream to store the content in the grid as comma-separated values.

LoadFromCSVStream
Stream with the content loaded in the method. Delimiter between cell data in the stream; default is Comma (','). Indicates if Column captions are loaded from values in the stream. Initial line number in the stream included in the grid content; default is 0. Indicates if empty lines in the stream are ignored in the method. Loads the grid from a file with delimited values for the columns and rows.

LoadFromCSVFile is a method used to delimited values from the file name in AFilename. It creates a temporary TFileStream instance that is used to load values from the file by calling the LoadFromCSVStream method.

ADelimiter is a character which identifies the delimiter used between column values on a row. Its default value is ',' (Comma) (decimal 44), but can be changed to another character value if needed.

Each row of values is terminated by a Carriage Return (Decimal 13) or Line Feed (Decimal 10) character. CR+LF may also be used. When either of the characters is encountered, they are processed as an end-of-line marker.

UseTitles indicates whether the first row of values are treated as fixed column titles in the grid. When set to True, each column value is stored as the caption for the corresponding entry in the Columns collection (when enabled). If Columns are not used, the values are stored as cell data in row number 0. When set to False, the first row is treated as cell data. The default value is True.

FromLine indicates the ordinal line number that is the first row loaded in the method. The default value is 0, and causes processing to begin at the first line. When a positive non-zero value is used, the lines are skipped by reading the corresponding number of end-of-line sequences.

SkipEmptyLines indicates whether blank lines are skipped when the row and column values are loaded in the method. The default value is True, and causes any row with a single empty column value to be skipped.

Use LoadFromCSVStream to load comma-separated values from a TStream instance.

Use SaveToCSVFile or SaveToCSVStream to store the content in the grid as comma-separated values.

File name with the content loaded in the method. Delimiter between cell values in the file; default is Comma (','). Indicates if column captions are loaded from values in the file. Initial line number from the file loaded in the method. Indicates if empty lines in the file are ignored in the method. Saves grid content as comma-separated values in the specified stream instance.

SaveToCSVStream is a method used to save values in the grid as comma-separated values in the specified stream instance.

AStream is the TStream instance where the grid content is written in the method.

ADelimiter is the character used as the delimiter between cell values on each row. The default value is ',' (Comma)(Decimal 44), but can be changed to another value if needed.

WriteTitles indicates whether column titles are written at the beginning of the stream. When set to True, column headers are included in the output. If the Columns collection has been enabled, the titles are read from the TGridColumn instances in the collection. If Columns has not been enabled, the cells in the FixedRows are written. When set to False, titles are omitted from the values output to the stream. The default value for the property is True.

VisibleColumnsOnly indicates whether the CSV output contains only visible columns on the grid. This capability is enabled when the Columns collection is used to defined the columns and their visibility. When set to True, any TGridColumn instance with its Visible property set to True is included in the output.

If Columns has not been enabled, all of the columns are by default visible and written to the stream - regardless of the value in the argument. The default value for the argument is False, and allows all columns to be written to the output stream.

SaveToCSVStream processes values in the grid in row order. Each column included in the output is written using the value in ADelimiter to separate the adjacent column values. A column value is enclosed by quote characters if its content contains whitespace or the delimiter character defined in ADelimiter. Each row is terminated with the end-of-line sequence used in the LCL.

No actions are performed in the method if either RowCount or ColCount are set to 0.

Please note: the stream position in AStream is not changed after values are written to the stream. It is positioned at the end of the stream. Use the Seek method or the Position property in AStream to change the stream position when needed.

Use SaveToCSVFile to save the grid content as comma-separated values to a given file name.

Use LoadFromCSVStream or LoadFromCSVFile to load the content in the grid control from comma-separated values in a stream or file.

TStream
Stream where the grid content is stored. Delimiter between cell values on the same row; default is Comma (','). Indicates that column titles are stored as the first row in the comma-separated values. False omits column titles in the output. Indicates if only visible columns are included in the CSV output. Saves grid content as comma-separated values in the specified file name.

SaveToCSVFile is a method used to store the contents of the grid control as comma-separated values in the specified file name.

AFileName contains the qualified path and file name where the CSV data is stored.

ADelimiter is the character used as the delimiter between cell values on each row. The default value is ',' (Comma)(Decimal 44), but can be changed to another value if needed.

WriteTitles indicates whether column titles are written at the beginning of the file. When set to True, column headers are included in the output. If the Columns collection has been enabled, the titles are read from the TGridColumn instances in the collection. If Columns has not been enabled, the cells in the FixedRows are written. When set to False, titles are omitted from the values output to the file. The default value for the property is True.

VisibleColumnsOnly indicates whether the CSV output contains only visible columns on the grid. This capability is enabled when the Columns collection is used to defined the columns and their visibility. When set to True, any TGridColumn instance with its Visible property set to True is included in the output.

If Columns has not been enabled, all of the columns are by default visible and written to the file - regardless of the value in the argument. The default value for the argument is False, and allows all columns to be written to the output file.

SaveToCSVFile creates a temporary TFileStream instance and calls SaveToCSVStream to process rows the and columns in the grid.

Use SaveToCSVStream to save the grid content as comma-separated values to a TStream instance.

Use LoadFromCSVStream or LoadFromCSVFile to load the content in the grid control from comma-separated values in a stream or file.

File name (with optional path) where CSV data is stored. Delimiter used between cell values in CSV output; default is Comma (','). Indicates if column captions are written as the first row of CSV data in the file. False omits column titles in the output. Indicates if only visible columns are included in the CSV output. Provides indexed access to a cell value by its column and row number.

Cells is an indexed String property used to read or write the content for a cell in the grid. The ACol and ARow indexes are used the access a value stored at the requested column and row position.

Reading the value causes the pointer to the cell in Celda to return its Text value.

Setting the value causes the pointer to the cell in Celda to be updated for the specified coordinates. An active cell editor will be cancelled if it is not locked, and the value in Modified is reset to False.

Use Objects to read or write an associated TObject instance for a given cell.

Column number for the cell value. Row number for the cell value. Provides indexed access to the list of values for the specified column number.

Cols is an indexed TStrings property which provides access to the list of values for the column number specified in Index. Read access calls MapGetColsRows to retrieve the TStrings instance used as the value for the property.

The Cols implementation in Lazarus is different than the one in Delphi. In Lazarus, a new TStrings instance is created and used to retrieve the cell content. The programmer is responsible for freeing the object after use. Failure to do so will result in a memory leak.

Cast the property value to TStringList to use the features introduced in the descendent class. For example:

Avoid a memory leak when updating column content:

// this will cause a memory leak because the returned TStrings is not freed Grid.Cols[1].CommaText := '1,2,3,4,5'; Grid.Cols[2].Text := 'a'+#13#10+'s'+#13#10+'d'+#13#10+'f'+#13#10+'g'; // avoids the memory leak from above Lst := TStringList.Create; Lst.CommaText := '1,2,3,4,5'; Grid.Cols[1] := Lst; Lst.Free; Lst := TStringList.Create; Grids.Text := 'a'+#13#10+'s'+#13#10+'d'+#13#10+'f'+#13#10+'g'; Grid.Cols[2] := Lst; Lst.Free;

Store values from a string grid column to a list box:

procedure TForm1.FillListBox1; var StrTempList: TStringList; begin StrTempList := TStringList(Grid.Cols[4]); if StrTempList <> nil then begin ListBox1.Items.Assign(StrTempList); StrTempList.Free; end; end;
Column number for the values. Provides indexed access to a TObject instance associated with the cell.

Objects is an indexed TObject property which is used to associate an object instance with the cell specified in the ACol and ARow index values. The property value can be any TObject descendant. The application must allocate and free the object instance, and must ensure it is cast to the correct type when retrieved.

While values in Cells and Objects are related, they are handled independently. The value in Objects is not changed when a new value is assigned to Cells.

Values stored in Objects are set to Nil when the Clean method is called to remove content in the grid. The application is responsible for allocating and freeing resources in Objects.

Values for the Objects property are not included in the grid data read and written during LCL component streaming. They are not handled by the LoadContent and SaveContent either. The property values are available at run-time only.

Column number for the cell with the object instance. Row number for the cell with the object instance. Provides indexed access to the list of column values for the specified row number.

Rows is an indexed TStrings property which provides access to the list with the String values for the columns in the row number specified in Index. Calls MapGetColsRows to retrieve the TStrings instance used as the value for the property.

The Rows implementation in Lazarus is different than the one in Delphi. In Lazarus, a new TStrings instance is created and used to retrieve the cell content. The programmer is responsible for freeing the object after use. Failure to do so will result in a memory leak.

Cast the property value to TStringList to use the features introduced in the descendent class. For example:

Avoid a memory leak when updating column content:

// this will cause a memory leak because the returned TStrings is not freed Grid.Rows[1].CommaText := '1,2,3,4,5'; Grid.Rows[2].Text := 'a'+#13#10+'s'+#13#10+'d'+#13#10+'f'+#13#10+'g'; // avoids the memory leak from above Lst := TStringList.Create; Lst.CommaText := '1,2,3,4,5'; Grid.Rows[1] := Lst; Lst.Free; Lst := TStringList.Create; Grids.Text := 'a'+#13#10+'s'+#13#10+'d'+#13#10+'f'+#13#10+'g'; Grid.Rows[2] := Lst; Lst.Free;

Store values from a string grid row to a list box:

procedure TForm1.FillListBox1; var StrTempList: TStringList; begin StrTempList := TStringList(Grid.Rows[4]); if StrTempList <> nil then begin ListBox1.Items.Assign(StrTempList); StrTempList.Free; end; end;
Row number for the values. Implements a grid specialized for textual content.

TStringGrid is a TCustomStringGrid descendant which implements a specialized grid for displaying textual content in a matrix of columns and rows.

TStringGrid is designed for use with string content stored in its cells. Internally, columns and rows in the class are mapped to TStringGridStrings instances used to store the values in the grid control. TStringGrid also allows a TObject instance to be stored for each cell in the grid using the Objects property.

TStringGrid sets the visibility for properties defined in the ancestor class. It has an overridden WSRegisterClass method to register properties (from older LCL versions) which are no longer used in LCL component streaming.

Additional information about grid usage is available on the Lazarus wiki in the following pages:

  • Grids Reference Page
  • TDrawGrid
  • TStringGrid
Uses the Color from the Parent control when enabled.

ParentColor determines if the control should use the Color from the Parent control, when enabled. The default value for the property is False in TStringGrid.

When this property is True, all changes to the Color of the parent will also be applied to the Color of the control, ensuring that they both contain same value. If the Color of the control is changed by the application, then ParentColor will be automatically set to False.

Using ParentColor when the Color value is clDefault can cause problems in resolving the actual color value. To obtain the Color property of a control while taking into account clDefault and ParentColor, use the GetColorResolvingParent method. This method might return a non-RGB color, but will never return clDefault. To obtain a purely RGB result use the GetRGBColorResolvingParent method.

TControl.ParentColor TControl.Color TControl.GetColorResolvingParent TControl.GetRGBColorResolvingParent
Deprecated. Use OnButtonClick instead.

Deprecated. Use OnButtonClick instead.

Draws a rubber banding rectangle.

Draws a dotted rubber banding rectangle around the provided cell rectangle.

DrawBits contains a Byte value that indicates the rectangle sides drawn in the routine. By default, all sides for the rectangle are drawn. Use the following byte values OR-ed together in DrawBits to specify the sides drawn:

BF_LEFT
Draws the left side of the rectangle.
BF_RIGHT
Draws the right side of the rectangle.
BF_TOP
Draws the top of the rectangle.
BF_BOTTOM
Draws the bottom of the rectangle.
Canvas where the rubber band rectangle is drawn. Coordinates for the rubber band rectangle. Color for the rubber band rectangle. Sides drawn for the rubber band rectangle. Ensures that a valid handle for a device context exists for the canvas. The canvas instance with a valid handle. Canvas examined in the routine. Ensures a canvas handle for a device context is freed. Canvas examined in the routine. Registers components in the Lazarus IDE.

Register is the procedure used to register components for use in the Lazarus IDE. Register calls the RegisterComponents routine to add the TStringGrid and TDrawGrid components to the Additional tab in the Lazarus IDE.

How to use Grids including StringGrids, DrawGrids and DbGrids.

Customizing Grids

Grids are components derived from the TCustomControl class and do not have a native widget associated with them. So they are not restricted by the look of the current interface theme. This can be both an advantage and a disadvantage: usually programmers want to create a uniform-look application. Lazarus grids are flexible enough to allow programmers to make them look similar to other native controls; alternatively they can customize the grid to obtain almost the same look in any platform or widget interface (with the exception of scroll bars, whose look is still determined by the current theme).

Some properties can affect the way the grid looks by acting when the cell is about to be painted in PrepareCanvas/OnPrepareCanvas by changing default canvas properties like brush color or font. Following is a list of such properties:

Properties and Events for Customizing Grids
Property Meaning
AlternateColor The user can change the background color that appears on alternate rows. This is to allow easy reading of grid rows data.
Color Sets the primary color used to draw non fixed cells' background.
FixedColor The color used to draw fixed cells' background.
Flat Eliminates the 3d look of fixed cells.
TitleFont Font used to draw the text in fixed cells.
TitleStyle

Changes the 3D look of fixed cells. There are 3 settings:

tsLazarus
The default look
tsNative
Tries to use an appearance that is in concordance with the current widgetset theme
tsStandard
A more contrasted look, like Delphi grids
AltColorStartNormal If True, alternate color is always in the second row after fixed rows; the first row after fixed rows will always be the default color. If False, default color is set to the first row as if there were no fixed rows.
BorderColor Sets the grid's border color used when Flat=True and BorderStyle is bsSingle.
EditorBorderStyle If set to bsNone under Windows the cell editors will not have the border, like in Delphi; set to bsSingle by default because the border can be theme specific in some widgetsets and to allow a uniform look.
FocusColor The color used to draw the current focused cell if UseXORFeatures is not set; by default this is clRed.
FocusRectVisible Turns on/off the drawing of focused cell.
GridLineColor Color of grid lines in non fixed area.
GridLineStyle Pen style used to draw lines in non fixed area, possible choices are: psSolid, psDash, psDot, psDashDot, psDashDotDot, psinsideFrame, psPattern, psClear; default is psSolid.
SelectedColor Color used to draw cell background on selected cells.
UseXORFeatures If set, focus rect is drawn using XOR mode so it should make visible the focus rect in combination with any cell color background. It also affects the way that moving columns look
DefaultDrawing Normally the grid prepares its grid canvas using properties according to the kind of cell that is being painted. If the user has written an OnDrawCell event handler, it is used to perform specified drawing operations for a given cell. DefaultDrawing (if set) also paints the cell background; if the user is taking full responsibility for drawing the cell it is better to turn off this so painting is not duplicated. In a StringGrid, if DefaultDrawing is set it draws the text in each cell.
AutoAdvance Where the cell cursor will go when pressing enter or tab/shift tab, or after editing.
ExtendedColSizing If True, the user can resize columns, not just at the headers, but anywhere along the column's height.

Other Properties that Affect Grid Appearance:

Options

This is a set of zero or more choices, with some elements that enable diverse functionality but others that are related directly with grid's look. Options can be set at design-time or run-time.

goFixedVertLine, goFixedHorzLine
Draws a vertical or horizontal line respectively, delimiting cells or columns in the fixed area; active by default.
goVertLine, goHorzLine
The same as previous, but for the normal browsable area. A grid can be made to simulate the visual appearance of a list box by removing both of these options.
goDrawFocusSelected
If this option is enabled, a selection background is painted in the focused cell in addition to the focused dotted rectangle. Please note: this doesn't work when the goRowSelect option is set; in such case the row is always painted as if goDrawFocusSelected is set.
goRowSelect
Selects the full row instead of individual cells.
goFixedRowNumbering
If set, grid will do numbering of rows in first fixed column.
goHeaderHotTracking
If set, the grid will try to show a different look when the mouse cursor is over any fixed cell. In order for this to work, desired cell zone needs to be enabled with the HeaderHotZones. Try combining this option with TitleStyle= tsNative to get themed hot tracking look.
goHeaderPushedLook
If set, this option enables a pushed look when clicking any fixed cell. The zone of "pushable" cells is enabled using HeaderPushedZones property.

Description of the Grid Drawing Process

Like other custom controls, the grid is drawn using the paint method. In general terms the grid is drawn by painting all rows, and each row by painting its individual cells. The process is as follows:

  • First, the visible cells area is determined: each row is tested to see if it intersects the canvas clipping region; if it's OK, then the visible area is painted by drawing columns of each row.
  • The column and row values are used to identify the cell that is about to be painted and again each column is tested for intersection with the clipping region; if everything is OK, some additional properties like the cell's rectangular extent and visual state are passed as arguments to the DrawCell method.
  • As the drawing process is running, the visual state of each cell is adjusted according to grid options and position within grid. The visual state is retained in a variable of type TGridDrawState which is a set with following elements:

    gdSelected The cell will have a selected look.
    gdFocused The cell will have a focused look.
    gdFixed Cell have to be painted with fixed cell look.
    gdHot the mouse is over this cell, so paint it with hot tracking look
    gdPushed the cell is being clicked, paint it with pushed look
  • DrawCell - The DrawCell method is virtual and may be overridden in descendent grids to do custom drawing. The information passed to DrawCell helps to identify which particular cell is being painted, the physical area occupied on the screen and its visible status. See DrawCell reference for details. For each cell the following occurs:

    • PrepareCanvas - If DefaultDrawing is True, the grid canvas is setup with default properties for brush and font based on current visual state. For several design and run-time properties, the text alignment is set to match programmer selection in custom columns if they exists. If DefaultDrawing is False, brush color is set to clWindow and Font color to clWindowText, the text alignment is set to the DefaultTextStyle value.
    • OnPrepareCanvas - If the programmer wrote an event handler for the OnPrepareCanvas event, it is called at this point. This event can be used for doing simple customization like changing a cell's background color, font's properties like color, font face and style, Text layout like different combinations of left, center, top, bottom, right alignment, etc. Any change made to the canvas for a particular cell in this event would be lost, because the next cell drawing will reset canvas again to a default state. So it's safe doing changes only for a particular cell or cells and forget about it for the rest. Using this event sometimes helps to avoid using the OnDrawCell grid event, where users would be forced to duplicate the grid's drawing code.
    • OnDrawCell - Next, if no handler for the OnDrawCell event was specified, the grid calls the DefaultDrawCell method which simply paints the cell background using the current canvas brush color and style. If the OnDrawCell handler exists, the grid first paints the cell background, but only if the DefaultDrawing was set; then it calls the OnDrawCell event to do custom cell painting. Usually programmers want to do custom drawing only for particular cells, but standard drawing for others: in this case, they can restrict custom operation to certain cell or cells by looking into ACol, ARow and AState arguments, and for other cells simply call the DefaultDrawCell method and let the grid to take care of it.
    • Text - At this point, if the DefaultDrawing is True, the cell's text content is painted (only for TStringGrid).
    • Grid lines - The last step for each cell is to paint the grid lines: if grid options goVertLine, goHorzLine, goFixedVertLine and goFixedHorzLine are specified the cell grid is drawn at this point. Grids with only rows or only cols can be obtained by changing these options. If the programmer elected to have a "themed" look it is done at this point also (see TitleStyle).
    • FocusRect - When all columns of the current row have been painted it is time to draw the focus rectangle for the current selected cell or for the whole row if the goRowSelect option is set.

Grid Cell Selection

The location of a grid's current (focused) cell (or row) can be changed using keyboard, mouse or through code. In order to change cell focus successfully to another position, we must test the target position to see if it is allowed to receive cell focus. When using the keyboard, AutoAdvance performs part of the process by finding what should be the next focused cell. When using mouse clicks or moving by code, focus will not move from the current cell unless the target cell is permitted to receive focus.

The grid calls SelectCell to see if a cell can be focused: if this function returns True, then the target cell identified with arguments aCol and aRow can be focused (the current implementation of TCustomGrid simply returns True). TCustomDrawGrid and hence TDrawGrid and TStringGrid override this method and check first if a cell is any wider than 0; normally you don't want a 0 width cell selected so a cell with this characteristics is skipped automatically in the process of finding a suitable cell. The overridden method SelectCell also calls the user configurable event OnSelectCell: this event receives the cell coordinates as arguments and always returns a default result of True.

If a cell can be focused and we are sure a movement will take place, the method BeforeMoveSelection is called; this in turns triggers the OnBeforeSelection event. This method's arguments are the coordinates for the new focused cell; at this point any visible editor is hidden too. The "before" word means that selection is not yet changed and current focused coordinates can be accessed with grid.Col and grid.Row properties.

After that, the internal focused cell coordinates are changed and MoveSelection is called; this method's purpose (if set) is to trigger the OnSelection event (this is a notification that the focused cell has changed and the new cell coordinates are available through grid.row and grid.col properties).

Note that is not good to use the OnSelectCell event to detect cell focus changes, as this event will be triggered several times even for the same cell in the process of finding a suitable cell. Is better to use OnBeforeSelection or OnSelection events for this purpose.

Using Cell Editors

Users can specify what editor will be used for a cell using one of two methods.

  1. Using a custom column and selecting the ButtonStyle of the column. In this method the user can select the style of the editor that will be shown. Available values are: cbsAuto, cbsEllipsis, cbsNone, cbsPickList, cbsCheckboxColumn.
  2. Using the OnSelectEditor Grid Event

    Here the user specifies in the Editor parameter which editor to use for a cell identified by aCol, ARow in a TCustomDrawGrid derived grid or TColumn in TCustomDBGrid. The public EditorByStyle() function takes as parameter one of the following values: cbsAuto, cbsEllipsis, cbsNone, cbsPickList, cbsCheckboxColumn.

    This method takes precedence over the first one using custom columns. A Custom cell editor can be specified here, with values specific to the cell, row or column.

Description of Editor Styles

The following is a description of the editor styles. They are enumerated values of type TColumnButtonStyle and so they are prefixed by 'cbs'. This type was used to remain compatible with Delphi's DBGrid.

  • cbsAuto - This is the default editor style for TCustomGrid derived grids. The TStringCellEditor derived from TCustomMaskEdit is specialized to edit single line strings and is used by default in TStringGrid and TDrawGrid. When using Custom Columns, if the programmer filled the Column's PickList property, this behaves as if cbsPickList editor style was set. For a TCustomDBGrid that has a field of type Boolean, it behaves as if cbsCheckBoxColumn editor style was specified. This is the recommended value for custom cell editors.
  • cbsEllipsis - This editor style is the most generic one. A button with ellipsis (...) appears in the editing cell and the programmer can use the OnEditButtonClick grid event to take any programmed action when the user presses the button. For example a calendar dialog could pop up to allow the user to select a specific date, a file open dialog could appear to find files, or a calculator could appear so the user could enter the numeric result of calculations, etc.

    • OnEditButtonClick is just a notification, to find out in which cell a button has been clicked by taking a look at the grid.Row and grid.Col properties.
    • A DBGrid has specific properties to retrieve the active column or field and because this event occurs in the active record, it could update the information in the active field.
    • This editor style is implemented using TButtonCellEditor, a direct descendant of TButton.
  • cbsNone - This editor style instructs the grid not to use any editor for a specific column; it behaves as if the cell were read-only.
  • cbsPickList - Used to present the user with a list of values that can be entered. This editor style is implemented using TPickListCellEditor, a component derived from TCustomComboBox. The list of values that are shown is filled in one of two ways depending on the method used to select the editor style.

    When using custom columns, programmers can enter a list of values using the PickList property for the column.

  • cbsCheckboxColumn - This editor style is at the moment only available in TDBGrid. If a field's contents associated with the column are restricted to a pair of values, for example, yes-no, True-false, on-off, 1-0, etc. then cbsCheckboxColumn is used to modify the appearance of a column by using a check box representation that the user can toggle by using a mouse click or pressing the SPACE key.

    • If a ButtonStyle for a column is set to cbsAuto and DBGrid detects that the field associated with the column is a Boolean field, then the grid uses this editor style automatically. This automatic selection can be disabled or enabled using the DBGrid OptionsExtra property; setting dgeCheckboxColumn element to False disables this feature.
    • The values that are used to recognize the checked or unchecked states are set in a column's properties ValueChecked and ValueUnchecked.
    • At any moment, the field value can be in one of three states: Unchecked, Checked or Grayed.