[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Grids' (#lcl)

TCustomGrid

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Implements the base class for grid controls.

Declaration

Source position: grids.pas line 743

type TCustomGrid = class(TCustomControl)

protected

  fGridState: TGridState;

  

Member with the current state for the grid (edited, updated, etc.).

  function RTLSign;

  

Gets the positive or negative multiplier used to adjust scroll values for BiDi mode.

  class procedure WSRegisterClass; override;

  

Registers this component class with the current WidgetSet.

  procedure AddSelectedRange;

  

Adds the current range selection to the array of selection rectangles for the control.

  procedure AdjustClientRect(); override;

  

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

  procedure AdjustEditorBounds(); virtual;

  

Updates the selected cell and sets the bounds for the optional cell Editor.

  procedure AfterMoveSelection(); virtual;

  

Signals the OnAfterSelection event handler.

  procedure AssignTo(); override;

  

Stores properties from the current grid class instance to the specified target.

  procedure AutoAdjustColumn(); virtual;

  

Adjusts column properties to accommodate the largest value in the specified column.

  procedure BeforeMoveSelection(); virtual;

  

Performs actions needed before a selection is moved.

  procedure BeginAutoDrag; override;

  

Starts an auto-drag operation in the grid control.

  function BoxRect();

  

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

  procedure CacheMouseDown();

  

Updates cached grid information when a mouse click occurs in the grid control.

  procedure CalcAutoSizeColumn(); virtual;

  

Calculates the size for an auto-sized column at the specified position.

  procedure CalcCellExtent(); virtual; overload; deprecated ;

  

Deprecated.

  procedure CalcFocusRect();

  

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

  procedure CalcMaxTopLeft;

  

Updates cached grid information for the visible area and scroll bars in the control.

  procedure CalcScrollbarsRange;

  

Updates the range, page, and thumb position for visible scroll bars.

  procedure CalculatePreferredSize(); override;

  

Gets the preferred width and height for the control.

  function CanEditShow; virtual;

  

Indicates whether the cell editor can be displayed and focused in the current column.

  function CanGridAcceptKey(); virtual;

  

Returns True if the grid is able to accept the given key.

  procedure CellClick(); virtual;

  

Processes a mouse click in the cell at the given coordinates.

  procedure CellExtent();

  

Gets the last column number for the cell extent at the specified column and row.

  procedure CheckLimits();

  

Checks column and row limits for the specified cell.

  procedure CheckLimitsWithError();

  

Checks column and row limits for the specified cell, with error trapping.

  procedure CMBiDiModeChanged(); message;

  

Handles the CM_BIDIMODECHANGED control message for the grid control.

  procedure CMMouseEnter(); message;

  

Handles the control message posted when the mouse enters a cell in the grid.

  procedure CMMouseLeave(); message;

  

Handles the control message posted when a mouse leaves a cell.

  procedure ColRowDeleted(); virtual;

  

Performs actions when a column or a row is deleted from the control.

  procedure ColRowExchanged(); virtual;

  

Performs a notification when column or row data at the specified positions are exchanged in the grid control.

  procedure ColRowInserted(); virtual;

  

Performs actions needed when column or row data is inserted into the grid control.

  procedure ColRowMoved(); virtual;

  

Performs actions when a column or row is moved in the grid.

  function ColRowToOffset();

  

Converts a column or row index to starting and ending pixels coordinates.

  function ColumnIndexFromGridColumn();

  

Gets the position of the specified column relative to the first column in the grid.

  function ColumnFromGridColumn();

  

Returns the grid column definition at the specified position in Columns.

  procedure ColumnsChanged();

  

Performs actions needed when one or more columns in the grid are changed.

  procedure ColWidthsChanged; virtual;

  

Performs actions needed when the widths for grid columns have been changed.

  function CreateColumns; virtual;

  

Allocates and configures resources for the Columns collection.

  procedure CheckNewCachedSizes(); virtual;

  

Checks the values for cached column sizes when they have been reset in the grid.

  procedure CreateWnd; override;

  

Creates and configures the widgetset handle for the grid control.

  procedure CreateParams(); override;

  

Initializes the window creation parameters with the settings for the control.

  procedure Click; override;

  

Performs actions needed when a mouse click occurs in the grid control.

  procedure DblClick; override;

  

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

  function DefaultColWidthIsStored;

  

Indicates if the DefaultColWidth property is available in component streaming.

  function DefaultRowHeightIsStored;

  

Indicates if the DefaultRowHeight property is available in component streaming.

  procedure DefineProperties(); override;

  

Defines non-published properties included during LCL component streaming.

  procedure DestroyHandle; override;

  

Destroys the handle for the control and all child controls.

  function DialogChar(); override;

  

Applies an accelerator key for a column in the grid.

  function DoCompareCells(); virtual;

  

Performs a comparison between the specified cells in the grid control.

  procedure DoCopyToClipboard; virtual;

  

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

  procedure DoCutToClipboard; virtual;

  

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

  procedure DoEditButtonClick(); virtual;

  

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

  procedure DoEditorHide; virtual;

  

Performs actions needed to hide the cell Editor in the grid control.

  procedure DoEditorShow; virtual;

  

Performs actions needed to show the cell Editor for the grid control.

  procedure DoExit; override;

  

Performs actions needed when the control loses focus.

  procedure DoEnter; override;

  

Performs actions needed when the grid control receives focus.

  procedure DoLoadColumn(); virtual;

  

Signals the OnLoadColumn event handler for the grid control (when assigned).

  procedure DoSaveColumn(); virtual;

  

Signals the OnSaveColumn event handler for the grid control (when assigned).

  function DoMouseWheel(); override;

  

Handles a mouse wheel operation for the grid control.

  function DoMouseWheelDown(); override;

  

Handles a mouse wheel down movement for the grid control.

  function DoMouseWheelUp(); override;

  

Handles a mouse wheel up movement for the grid control.

  function DoMouseWheelLeft(); override;

  

Handles a mouse wheel scroll left message for the control.

  function DoMouseWheelRight(); override;

  

Handles a mouse wheel scroll right message for the control.

  procedure DoAutoAdjustLayout(); override;

  

Performs actions to automatically apply the layout policy with the specified scaling factors.

  procedure DoOnChangeBounds; override;

  

Signals OnChangeBounds event handlers for the control.

  procedure DoOPDeleteColRow();

  

Performs a delete operation for a column or a row.

  procedure DoOPExchangeColRow();

  

Performs an exchange of values for the columns or rows with the specified indexes.

  procedure DoOPInsertColRow();

  

Performs an insert operation for a column or a row at the specified position.

  procedure DoOPMoveColRow();

  

Performs a move operation for the column or row at the specified position.

  procedure DoPasteFromClipboard; virtual;

  

Pastes data from the clipboard into the grid control.

  procedure DoPrepareCanvas(); virtual;

  

Performs actions needed to prepare the canvas for a drawing operation.

  procedure DoOnResize; override;

  

Performs actions needed when the grid control is resized.

  procedure DoSetBounds(); override;

  

Captures the current client width prior to setting the new bounds for the control.

  function DoUTF8KeyPress(); override;

  

Applies a UTF-8-encoded character to the active cell editor in the control.

  procedure DrawBorder;

  

Draws the border for the grid control.

  procedure DrawAllRows; virtual;

  

Draws all of the rows for the grid.

  procedure DrawFillRect();

  

Draws the fill rectangle on the specified canvas.

  procedure DrawCell(); virtual;

  

Draws a cell using a given state at the specified grid location (Col, Row, rectangle).

  procedure DrawCellGrid(); virtual;

  

Draws cell grid lines for the control.

  procedure DrawTextInCell(); virtual;

  

Draws the text for a non-fixed cell in the grid.

  procedure DrawThemedCell();

  

Draws a cell using the theme services for the specified grid drawing state.

  procedure DrawCellText(); virtual;

  

Draws the specified text in the given text rectangle.

  procedure DrawGridCheckboxBitmaps(); virtual;

  

Draws a check box bitmap which represents the given state in a cell.

  procedure DrawButtonCell();

  

Draws a cell in a button-style column.

  procedure DrawColRowMoving;

  

Draws a column or row when dragging is in effect.

  procedure DrawColumnText(); virtual;

  

Draws the text and image for a grid column title at the specified cell coordinates.

  procedure DrawColumnTitleImage();

  

Draws the image(s) used in the column title at the specified index in the grid.

  procedure DrawEdges;

  

Draws the edges (and filled background) of the client area for the control.

  procedure DrawFocusRect(); virtual;

  

Draws the focus rectangle for the specified cell.

  procedure DrawRow(); virtual;

  

Draws the columns for the specified row in the grid control.

  procedure EditButtonClicked();

  

Signals the OnEditButtonClick or OnButtonClick event handler (when assigned).

  procedure EditordoGetValue; virtual;

  

Gets the value for the cell Editor.

  procedure EditordoResetValue; virtual;

  

Resets the value in the selected cell when a visible editor is cancelled or hidden.

  procedure EditordoSetValue; virtual;

  

Sets the mask and value for a visible cell editor in the grid control.

  function EditorCanAcceptKey(); virtual;

  

Returns True if the Editor is able to accept the specified UTF-8 character.

  function EditorIsReadOnly; virtual;

  

Determines if the current column number is defined as read-only.

  procedure EditorHide; virtual;

  

Hides a visible cell editor in the grid control.

  function EditorLocked;

  

Returns True if the Editor is locked, i.e. unable to accept input or make changes.

  function EditingAllowed(); virtual;

  

Indicates if the grid and specified column allow editing.

  procedure EditorSelectAll;

  

Performs actions to select the entire content in the current cell.

  procedure EditorShow(); virtual;

  

Displays the Editor for the selected cell.

  procedure EditorShowInCell(); virtual;

  

Shows the cell content for the Editorin situ.

  procedure EditorWidthChanged(); virtual;

  

Performs actions needed when the width for a cell Editor has been changed.

  function FirstGridColumn; virtual;

  

Gets the position of the first column after any fixed columns in the grid.

  function FixedGrid;

  

Determines if all columns or all rows in the grid are fixed.

  procedure FontChanged(); override;

  

Performs actions needed when the font for the control is changed.

  procedure GetAutoFillColumnInfo(); virtual;

  

Gets auto-fill information for the specified column.

  function GetCellHintText(); virtual;

  

Gets the hint for the specified cell using the Options enabled in the grid control.

  function GetCells(); virtual;

  

Gets the cell content at the specified column and row numbers.

  function GetColumnAlignment();

  

Gets the horizontal Alignment for the specified column.

  function GetColumnColor();

  

Gets the Color used to render the background for the specified column number.

  function GetColumnFont();

  

Gets the font used to render values for the specified column.

  function GetColumnLayout();

  

Gets the vertical text Layout value for the specified column.

  function GetColumnReadonly();

  

Returns True if the column is marked as ReadOnly.

  function GetColumnTitle();

  

Gets the text displayed as the column title for the specified column number.

  function GetColumnWidth();

  

Gets the width of the column at the specified column number.

  function GetDeltaMoveNext(); virtual;

  

Returns the relative cell coordinates for the next cell in the grid navigation order.

  function GetDefaultColumnAlignment(); virtual;

  

Gets the default horizontal alignment used for values in the grid control.

  function GetDefaultColumnWidth(); virtual;

  

Gets the default width used for the specified column.

  function GetDefaultColumnLayout(); virtual;

  

Gets the default vertical layout for text in the specified column.

  function GetDefaultColumnReadOnly(); virtual;

  

Gets the default setting for the ReadOnly flag in the specified column number.

  function GetDefaultColumnTitle(); virtual;

  

Gets the default text used as the column title for the specified column number.

  function GetDefaultEditor(); virtual;

  

Gets the default cell editor for the specified column.

  function GetDefaultRowHeight; virtual;

  

Gets the default height for a row in the grid control.

  function GetGridDrawState();

  

Gets the grid drawing state for the cell with the specified column and row numbers.

  procedure GetImageForCheckBox(); virtual;

  

Gets the bitmap used to draw check box columns in the grid.

  function GetScrollBarPosition();

  

Gets the position for the specified scroll bar.

  function GetSmoothScroll(); virtual;

  

Gets the smooth scroll setting in the Options for the grid.

  procedure GetSBVisibility(); virtual;

  

Gets the values for the scroll bar visibility flags in the control.

  procedure GetSBRanges(); virtual;

  

Gets the range values for the scroll bars when visible.

  procedure GetSelectedState(); virtual;

  

Gets the effective selected state using the control Options and the grid draw state.

  function GetEditMask(); virtual;

  

Gets the edit mask for the specified cell.

  function GetEditText(); virtual;

  

Gets the text displayed in the Editor for the specified cell.

  function GetFixedcolor; virtual;

  

Gets the value for the FixedColor property.

  function GetFirstVisibleColumn;

  

Gets the column number for the first visible non-fixed column in the grid.

  function GetFirstVisibleRow;

  

Gets the row number for the first visible non-fixed row in the grid.

  function GetLastVisibleColumn;

  

Gets the column number for the last visible non-fixed column in the grid.

  function GetLastVisibleRow;

  

Gets the row number for the last visible non-fixed row in the grid.

  function GetSelectedColor; virtual;

  

Gets the value for the SelectedColor property.

  function GetTitleShowPrefix();

  

Gets the prefix option for the title in the specified column number.

  function GetPxTopLeft;

  

Gets a TPoint instance with the top and left coordinates for the first visible, non-fixed row in the grid control.

  function GetTruncCellHintText(); virtual;

  

Gets the truncated version of the hint for the cell at the specified position.

  function GridColumnFromColumnIndex();

  

Gets the ordinal position in Columns for the visible column specified in ColumnIndex.

  procedure GridMouseWheel(); virtual;

  

Performs actions to apply a mouse wheel message to the grid control.

  procedure HeaderClick(); virtual;

  

Performs actions needed when a mouse click occurs in a fixed header for a grid column or row.

  procedure HeaderSized(); virtual;

  

Performs actions needed when a column or a row has been resized.

  procedure HeaderSizing(); virtual;

  

Performs actions to resize a column or row to the specified size.

  procedure HideCellHintWindow;

  

Cancels the current hint display and restores the saved hint for the grid control.

  procedure InternalSetColCount();

  

Performs actions needed to set the column count in the grid control.

  procedure InvalidateCell();

  

Renders a cell invalid, and redraws the cell if required.

  procedure InvalidateFromCol();

  

Invalidates cells starting at the specified column number; all rows from the start position are affected.

  procedure InvalidateGrid;

  

Invalidates the client area for the grid control.

  procedure InvalidateFocused;

  

Invalidates a focused or highlighted cell or row.

  function IsColumnIndexValid();

  

Indicates if the specified index position is valid for the columns in the grid.

  function IsRowIndexValid();

  

Indicates if the specified index position is valid for the rows in the grid.

  function IsColumnIndexVariable();

  

True when the column index is in the range FixedCols..ColCount-1.

  function IsRowIndexVariable();

  

Indicates if the specified row is a valid, non-fixed row in the grid control.

  function GetIsCellTitle(); virtual;

  

Indicates if the cell at the specified position is a fixed column header.

  function GetIsCellSelected(); virtual;

  

Gets the value for the indexed IsCellSelected property.

  function IsEmptyRow();

  

Indicates if all non-fixed cells in the specified row are empty.

  function IsMouseOverCellButton();

  

Indicates if the specified mouse position is over a cell defined with a button column cell editor.

  procedure KeyDown(); override;

  

Handles key down events for the grid control.

  procedure KeyUp(); override;

  

Signals the OnKeyUp event handler (when assigned).

  procedure KeyPress(); override;

  

Applies the specified key press character to the control.

  procedure LoadContent(); virtual;

  

Loads values for the grid control from the specified XML configuration file.

  procedure LoadGridOptions(); virtual;

  

Loads design-time values for the Options in a grid from an XML configuration file.

  procedure Loaded; override;

  

Performs actions when the component has been loaded using LCL component streaming.

  procedure LockEditor;

  

Locks the Editor so that it cannot accept input or changes.

  function MouseButtonAllowed(); virtual;

  

Indicates if the specified mouse button is a mouse down event used in the control.

  procedure MouseDown(); override;

  

Handles mouse down events for the grid control.

  procedure MouseMove(); override;

  

Applies a change in the mouse pointer position to the grid control.

  procedure MouseUp(); override;

  

Handles a mouse up event for the grid control.

  function MoveExtend();

  

Moves the selected cell or extends a selection using the specified column and row values.

  function MoveNextAuto();

  

Moves to the next cell in the auto-advance sequence.

  function MoveNextSelectable(); virtual;

  

Moves to the next selectable cell in the specified direction.

  procedure MoveSelection; virtual;

  

Signals the OnSelection event handler for a new mouse selection.

  procedure Notification(); override;

  

Performs actions needed when the specified component is added to or removed from the control.

  function OffsetToColRow();

  

Determines the index of a column or row for a the specified offset.

  procedure Paint; override;

  

Draws the edges, borders, and rows in the grid control.

  procedure PickListItemSelected();

  

Signals the OnPickListSelect event handler when a selection is made in a picklist.

  procedure PrepareCanvas(); virtual;

  

Prepares the canvas for drawing the cell at the specified location.

  procedure PrepareCellHints(); virtual;

  

Prepares the control to display hints for a cell.

  procedure ResetDefaultColWidths; virtual;

  

Restores the default width for columns in the grid.

  procedure ResetEditor;

  

Resets the value in the cell Editor, and optionally re-displays and selects it content.

  procedure ResetLastMove;

  

Resets the member used to track the last row or column movement.

  function ResetOffset();

  

Resets cached column (Top/Left) and row offsets.

  procedure ResetSizes; virtual;

  

Resets the internal column sizes.

  procedure ResizeColumn();

  

Resizes the specified column number to the given width.

  procedure ResizeRow();

  

Resizes the specified row number to the given height.

  procedure RowHeightsChanged; virtual;

  

Performs actions needed when the values in RowHeights have been changed.

  procedure SaveContent(); virtual;

  

Saves design-time configuration, column and row settings, and data to the specified XML configuration file.

  procedure SaveGridOptions(); virtual;

  

Saves grid options to the specified XML configuration file.

  procedure ScrollBarRange();

  

Sets range information for the specified scroll bar.

  procedure ScrollBarPosition();

  

Sets the position for the specified scroll bar to the given value.

  function ScrollBarIsVisible();

  

Returns True if the specified scroll bar is visible.

  procedure ScrollBarPage();

  

Updates the page size for the specified scroll bar.

  procedure ScrollBarShow();

  

Displays or hides scroll bar(s) for the grid control.

  function ScrollBarAutomatic(); virtual;

  

Indicates whether an automatic scroll bar of the given type is used on the grid control.

  procedure ScrollBy(); override;

  

Scrolls the non-fixed area for the control by the specified delta values.

  procedure SelectEditor; virtual;

  

Gets the cell editor for the current cell, and sets its PopupMenu.

  function SelectCell(); virtual;

  

Determines whether the specified cell can be selected in the grid control.

  procedure SetCanvasFont();

  

Sets the Canvas font to the specified value.

  procedure SetColCount(); virtual;

  

Sets the value in the ColCount property.

  procedure SetColor(); override;

  

Sets the value in the Color property.

  procedure SetColRow();

  

Makes the specified column and row a selected cell in the grid control.

  procedure SetCursor(); override;

  

Changes the cursor shape in the grid to the specified value.

  procedure SetEditText(); virtual;

  

Sets the value used in the cell Editor to the specified text.

  procedure SetBorderStyle(); override;

  

Sets the value for the BorderStyle property.

  procedure SetFixedcolor(); virtual;

  

Sets the value for the FixedColor property.

  procedure SetFixedCols(); virtual;

  

Sets the value for the FixedCols property.

  procedure SetFixedRows(); virtual;

  

Sets the value for the FixedRows property.

  procedure SetRawColWidths();

  

Sets the width for the specified column number in the internal list.

  procedure SetSelectedColor(); virtual;

  

Sets the value for the SelectedColor property.

  procedure SetFadeUnfocusedSelection();

  

Sets the value for the FadeUnfocusedSelection property.

  procedure ShowCellHintWindow();

  

Gets and displays the cell hint(s) for the current cell in the grid.

  procedure SizeChanged(); virtual;

  

Performs actions needed when the number of columns or rows has been changed.

  procedure Sort(); virtual;

  

Sorts rows or columns in the grid.

  procedure StartPushCell;

  

Starts an operation to render a cell in its "pushed" state.

  procedure TopLeftChanged; virtual;

  

Signals the OnTopLeftChanged event handler (when assigned) at run-time.

  function TryMoveSelection();

  

Tries to move the cell selection by or to the specified column and row values.

  procedure UnLockEditor;

  

Decrements the lock count for the cell Editor following a call to LockEditor.

  procedure UnprepareCellHints; virtual;

  

Re-implemented in descendent classes.

  procedure UpdateHorzScrollBar(); virtual;

  

Updates the horizontal scroll bar to use the specified range, page, and position.

  procedure UpdateSelectionRange;

  

Updates the selection range when the current selection in the grid has changed.

  procedure UpdateVertScrollbar(); virtual;

  

Updates the vertical scroll bar to use the specified visibility, range, and page values.

  procedure UpdateBorderStyle;

  

Updates the border style used for the control.

  function ValidateEntry(); virtual;

  

Validates the value for the specified cell.

  procedure VisualChange; virtual;

  

Updates the grid after changes to the visual properties in the control.

  procedure WMSize(); message;

  

Handles a WM_SIZE window message for the control.

  procedure WMHScroll(); message;

  

Handles the system message for horizontal scrolling.

  procedure WMVScroll(); message;

  

Handles the system message for vertical scrolling.

  procedure WMKillFocus(); message;

  

Handles the LM_KILLFOCUS message for the control.

  procedure WMSetFocus(); message;

  

Handles the LM_KILLFOCUS message for the control.

  procedure WndProc(); override;

  

Extends the message processing loop for the grid control.

  property AllowOutboundEvents: Boolean; [rw]

  

Allows a mouse click on unused space in the control, and moves the cursor to the nearest valid cell.

  property AlternateColor: TColor; [rws]

  

Color used for the background in alternate rows in the grid.

  property AutoAdvance: TAutoAdvance; [rw]

  

Direction used when automatically moving the selection to the next selectable cell.

  property AutoEdit: Boolean; [rw]

  

Indicates if edit mode is automatically entered when a cell is selected.

  property AutoFillColumns: Boolean; [rw]

  

Indicates whether columns are automatically resized to fill the visible area in the grid.

  property BorderStyle: TBorderStyle; [rw]

  

Drawing style used for the borders on the control.

  property BorderColor: TColor; [rw]

  

The color used for the border on the control.

  property CellHintPriority: TCellHintPriority; [rw]

  

Identifies how text is combined to form the Hint property.

  property Col: Integer; [rw]

  

Column index for the selected grid cell.

  property ColCount: Integer; [rw]

  

Number of columns in the grid.

  property ColRow: TPoint; [rw]

  

Provides access to current column and row numbers as a TPoint instance.

  property ColRowDraggingCursor: TCursor; [rw]

  

Cursor shape displayed when a column or row is dragged in the grid control.

  property ColRowDragIndicatorColor: TColor; [rw]

  

Color used to render the drag cursor when a column or row is dragged in the grid.

  property ColSizingCursor: TCursor; [rw]

  

Cursor shape displayed when a column is resized.

  property ColumnClickSorts: Boolean; [rw]

  

Indicates if clicking a column header changes its sort order.

  property Columns: TGridColumns; [rws]

  

Definitions for the columns displayed the grid.

  property ColWidths []: Integer; [rw]

  

Provides indexed access to the Width for a column in the grid.

  property DefaultColWidth: Integer; [rws]

  

Default width used for grid columns.

  property DefaultRowHeight: Integer; [rws]

  

Default row height for newly created grid rows.

  property DefaultDrawing: Boolean; [rw]

  

Indicates if the default drawing mechanism is used to draw the background and text for cells.

  property DefaultTextStyle: TTextStyle; [rw]

  

Default style used to display text including alignment, layout, wrapping, et. al.

  property DisabledFontColor: TColor; [rw]

  

Color used to draw text in the grid when Enabled is set to False.

  property DragDx: Integer; [rw]

  

The amount (DeltaX) by which an object should be dragged.

  property Editor: TWinControl; [rw]

  

The editor control used to modify the value in the current cell.

  property EditorBorderStyle: TBorderStyle; [rw]

  

The border style for the Editor control.

  property EditorMode: Boolean; [rw]

  

True when the Editor is ready to modify the value for the current cell.

  property EditorKey: Boolean; [rw]

  

Indicates if the last key event was triggered by the cell Editor for the grid control.

  property EditorOptions: Integer; [rw]

  

The option flags sent to the Editor control in the grid.

  property EditorShowing: Boolean; [rw]

  

True when the cell Editor for the grid control has been displayed.

  property ExtendedColSizing: Boolean; [rw]

  

Indicates if extended column sizing is enabled in the grid.

  property ExtendedRowSizing: Boolean; [rw]

  

Indicates if extended row sizing is enabled for rows in the grid.

  property ExtendedSelect: Boolean; [rw]

  

Indicates whether a selection can extend beyond the visible boundary for the grid.

  property FastEditing: Boolean; [rw]

  

Indicates if "Fast Editing" is enabled in the grid.

  property AltColorStartNormal: Boolean; [rw]

  

Indicates if alternate row coloring starts with the normal row color.

  property FixedCols: Integer; [rw]

  

The number of fixed columns in the grid.

  property FixedRows: Integer; [rw]

  

Number of the fixed rows in the grid.

  property FixedColor: TColor; [rw]

  

The color used for the fixed cells in the grid.

  property FixedGridLineColor: TColor; [rw]

  

Color used to draw the separator lines for fixed grid cells.

  property FixedHotColor: TColor; [rw]

  

The color used for hot-lighted fixed cells in the grid.

  property Flat: Boolean; [rw]

  

Indicates if cells are displayed using a Flat appearance.

  property FocusColor: TColor; [rw]

  

The color used to draw the focus rectangle when a cell has focus.

  property FocusRectVisible: Boolean; [rw]

  

Indicates if the focus rectangle is displayed for the control.

  property GCache: TGridDataCache; [r]

  

Contains cached data about the visual layout and state for the grid control.

  property GridFlags: TGridFlags; [rw]

  

Contains grid-specific state flags active for the control.

  property GridHeight: Integer; [r]

  

Total height for all of the rows in the grid control.

  property GridLineColor: TColor; [rw]

  

Color used for the grid lines on the control.

  property GridLineStyle: TPenStyle; [rw]

  

Style used to draw the grid lines on the control.

  property GridLineWidth: Integer; [rw]

  

Width (thickness) for grid lines drawn on the control.

  property GridWidth: Integer; [r]

  

Total width for all columns in the Grid including non-visible columns.

  property HeaderHotZones: TGridZoneSet; [rw]

  

Contains the grid zones which are hot-lighted (hovered) on the control.

  property HeaderPushZones: TGridZoneSet; [rw]

  

Contains the grid zones which are drawn in a "pushed" state on the control.

  property ImageIndexSortAsc: TImageIndex; [rw]

  

Ordinal position for the image used when a column is sorted in ascending order.

  property ImageIndexSortDesc: TImageIndex; [rw]

  

Ordinal position for the image used when a column is sorted in descending order.

  property TabAdvance: TAutoAdvance; [rw]

  

Controls the behavior for Tab navigation in the grid control.

  property TitleImageList: TImageList; [rw]

  

The list with images displayed in column titles.

  property TitleImageListWidth: Integer; [rw]

  

Stores the default width for images used in the title area for fixed cells.

  property InplaceEditor: TWinControl; [r]

  

Cell editor for the grid control.

  property IsCellSelected []: Boolean; [r]

  

Provides indexed access to the selected state for a cell by its column and row number.

  property LeftCol: Integer; [rw]

  

Column number for the first visible column on the left edge of the grid.

  property MouseWheelOption: TMouseWheelOption; [rw]

  

Sets the mouse wheel behavior for the grid control.

  property Options: TGridOptions; [rw]

  

Contains the set of optional features and/or behaviors enabled for the grid control.

  property Options2: TGridOptions2; [rw]

  

Contains additional options for scrolling and editor behavior enabled in the grid control.

  property RangeSelectMode: TRangeSelectMode; [rw]

  

Controls the range selection mode used for the grid.

  property Row: Integer; [rw]

  

Row number for the selected grid cell.

  property RowCount: Integer; [rw]

  

Number of rows in the grid.

  property RowSizingCursor: TCursor; [rw]

  

Cursor shape displayed when the row height is resized.

  property RowHeights []: Integer; [rw]

  

Provides indexed access to the height for each row in the grid.

  property SaveOptions: TSaveOptions; [rw]

  

Options which control the information saved and loaded for the grid control.

  property SelectActive: Boolean; [rw]

  

Indicates if a Selection is active in the grid control.

  property SelectedColor: TColor; [rw]

  

Color used for selected cells in the grid.

  property FadeUnfocusedSelection: Boolean; [rw]

  

Indicates if a special color is used for selected cells when the control loses focus.

  property SelectedColumn: TGridColumn; [r]

  

The column instance for the currently selected cell in the grid control.

  property Selection: TGridRect; [rw]

  

Rectangle with the current cell selections in the grid control.

  property ScrollBars: TScrollStyle; [rw]

  

Scrollbars displayed for the grid control.

  property StrictSort: Boolean; [rw]

  

Indicates if strict sorting is used.

  property TitleFont: TFont; [rws]

  

The font used for text in a column title.

  property TitleStyle: TTitleStyle; [rw]

  

The drawing style used for the fixed column titles.

  property TopRow: Integer; [rw]

  

The first visible row in the grid.

  property UseXORFeatures: Boolean; [rw]

  

When True, the dotted focus rectangle is painted using an XOR raster operation.

  property ValidateOnSetSelection: Boolean; [rw]

  

Controls validation when the text for the selected cell is changed.

  property VisibleColCount: Integer; [rs]

  

The number of visible columns in the grid control.

  property VisibleRowCount: Integer; [rs]

  

The number of visible rows in the grid control.

  property OnAfterSelection: TOnSelectEvent; [rw]

  

Event handler signalled after a new Selection is made in the grid.

  property OnBeforeSelection: TOnSelectEvent; [rw]

  

Event handler signalled before changing the Selection in the grid control.

  property OnCheckboxToggled: TToggledCheckboxEvent; [rw]

  

Event handler signalled when the value for a check box cell is toggled.

  property OnCompareCells: TOnCompareCells; [rw]

  

Event handler signalled to compare the content in grid cells.

  property OnPrepareCanvas: TOnPrepareCanvasEvent; [rw]

  

Event handler signalled to prepare the Canvas to draw the grid.

  property OnDrawCell: TOnDrawCell; [rw]

  

Event handler signalled to draw a cell in the grid control.

  property OnEditButtonClick: TNotifyEvent; [rw] deprecated ;

  

Event handler signalled when the button in a cell Editor is clicked. Deprecated.

  property OnButtonClick: TOnSelectEvent; [rw]

  

Event handler signalled when a button-style cell Editor control is clicked.

  property OnPickListSelect: TNotifyEvent; [rw]

  

Event handler signalled when an item is selected from a pick list-style Editor control.

  property OnSelection: TOnSelectEvent; [rw]

  

Event handler signalled when an area is selected in the grid control.

  property OnSelectEditor: TSelectEditorEvent; [rw]

  

Event handler signalled to select an Editor control for the current grid cell.

  property OnTopLeftChanged: TNotifyEvent; [rw]

  

Event handler signalled when the top left cell in the visible area of the control is changed.

  property OnUserCheckboxBitmap: TUserCheckBoxBitmapEvent; [rw]

  

Event handler signalled to get the user-defined bitmap used for a check box cell.

  property OnUserCheckboxImage: TUserCheckBoxImageEvent; [rw]

  

Event handler signalled to get the user-defined image used for a check box cell.

  property OnValidateEntry: TValidateEntryEvent; [rw]

  

Event handler signalled to perform validation for a cell value.

  function FlipRect();

  

Flips coordinates for the specified cell rectangle when BiDiMode or RTL alignment is used.

  function FlipPoint();

  

Flips cell coordinates for the specified point on the parent rectangle when BiDiMode or RTL alignment is used.

  function FlipX();

  

Flips the horizontal position in the client when BiDiMode or RTL alignment is used.

  property OnGetCellHint: TGetCellHintEvent; [rw]

  

Gets the hint text for a cell.

  property OnSaveColumn: TSaveColumnEvent; [rw]

  

Event handler signalled when an entry in Columns is saved to a configuration file using the SaveContent method.

  property OnLoadColumn: TSaveColumnEvent; [rw]

  

Event handler signalled when a column is loaded in the LoadColumns method.

public

  constructor Create(); override;

  

Constructor for the class instance.

  destructor Destroy; override;

  

Destructor for the class instance.

  procedure Invalidate; override;

  

Performs a request to redraw the control.

  procedure EditingDone; override;

  

Signals the OnEditingDone event handler.

  procedure AdjustInnerCellRect();

  

Adjusts the cell rectangle to account for grid lines drawn around a cell.

  procedure AutoAdjustColumns; virtual;

  

Automatically adjusts columns sizes to the width of their content.

  procedure BeginUpdate;

  

Begins an update to the grid control.

  function CellRect();

  

The coordinates for the specified cell (ACol, ARow) as a standard rectangle (TRect).

  function CellToGridZone();

  

Determines the grid zone for the specified cell.

  procedure CheckPosition;

  

Determines if the cell can be selected, or finds a suitable position using auto-advance.

  function ClearCols;

  

Clears the values in the FixedCols and Cols properties.

  function ClearRows;

  

Clears the cached fixed rows and row count values for the grid control.

  procedure Clear;

  

Clears all cells in the grid control.

  procedure ClearSelections;

  

Clears the current range selection(s) and redraws the grid control.

  function EditorByStyle(); virtual;

  

Selects a cell Editor control with the specified style.

  procedure EditorKeyDown();

  

Implements the OnKeyDown event handler for the cell editor.

  procedure EditorKeyPress();

  

Implements the OnKeyPress event handler for the cell editor.

  procedure EditorUTF8KeyPress();

  

Implements the UTF-8 key press handler for the editor in the grid control.

  procedure EditorKeyUp();

  

Implements the OnKeyUp event handler for the cell editor.

  procedure EditorTextChanged(); virtual;

  

Updates the grid control when the value in a cell Editor is changed.

  procedure EndUpdate();

  

Finishes an active update to the grid control.

  procedure EraseBackground(); override;

  

Clears the background for the grid control.

  procedure FixDesignFontsPPI(); override;

  

Adjusts fonts in the control to the specified design-time PixelsPerInch.

  function Focused; override;

  

Indicates if the grid is focused or has an active focused cell Editor.

  function HasMultiSelection;

  

Indicates if multi-select range selection mode is enabled and in use for the grid.

  procedure HideSortArrow;

  

Hides the arrow drawn as the sort indicator for a column.

  procedure InvalidateCol();

  

Invalidates all cells in the specified column, and causes them to be redrawn.

  procedure InvalidateRange();

  

Invalidates a cell range in the grid and causes it to be redrawn.

  procedure InvalidateRow();

  

Invalidates the drawing rectangle for the specified row number.

  function IsCellVisible();

  

Determines whether the specified cell is visible.

  function IsFixedCellVisible();

  

Determines if the specified cell is a visible fixed header cell in the grid.

  procedure LoadFromFile(); virtual;

  

Loads grid data from a file with the specified file name.

  procedure LoadFromStream(); virtual;

  

Loads grid data from the specified stream.

  function MouseCoord();

  

Gets the cell coordinates for the specified mouse pointer position.

  function MouseToCell();

  

Converts the specified mouse screen coordinates to cell coordinates.

  function MouseToLogcell();

  

Converts mouse coordinates to logical cell coordinates on the grid.

  function MouseToGridZone();

  

Converts the specified coordinates for the mouse pointer to the grid zone where they are located.

  procedure SaveToFile(); virtual;

  

Saves grid information to a file with the specified name.

  procedure SaveToStream(); virtual;

  

Saves grid information to the specified stream.

  procedure ScaleFontsPPI(); override;

  

Resizes fonts using a target PPI and a scaling factor.

  procedure SetFocus; override;

  

Gives focus to the grid control.

  property CursorState: TGridCursorState; [r]

  

Current cursor state for the grid control.

  property SelectedRange []: TGridRect; [r]

  

Provides indexed access to TGridRect values in the currently selected range.

  property SelectedRangeCount: Integer; [r]

  

Number of cell rectangles in the selected range for the grid.

  property SortOrder: TSortOrder; [rw]

  

Controls the order used for the sort column (ascending or descending).

  property SortColumn: Integer; [r]

  

Column number used to sort the rows in the grid.

  property TabStop: Boolean;

  

Indicates if keyboard navigation to/from the control is enabled using the Tab or Shift+Tab keys.

end;

Inheritance

TCustomGrid

  

Implements the base class for grid controls.

|

TCustomControl

  

The base class for windowed controls which paint themselves.

|

TWinControl

  

Implements a windowed control which can contain other child controls.

|

TControl

  

The base class for visible controls.

|

TLCLComponent

  

The base class for LCL components which have an associated widget.

|

TComponent,IUnknown,IInterfaceComponentReference

|

TPersistent,IFPObserved

|

TObject

Description

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:

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:

See also

TStringGrid

  

Implements a grid specialized for textual content.

TDrawGrid

  

Implements a custom-drawn grid control.

HowToUseGrids

  

How to use Grids including StringGrids, DrawGrids and DbGrids.


Version 3.2 Generated 2024-02-25 Home