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

# TStringGrid

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

Implements a grid specialized for textual content.

## Declaration

Source position: grids.pas line 1834

`type TStringGrid = class(TCustomStringGrid)`
`protected`
`class procedure WSRegisterClass; override;` |  | Registers this component class with the current WidgetSet.
`public`
`property Modified: Boolean;` |  | Indicates whether the content in the grid cells has been changed.
`property InplaceEditor: TWinControl;` |  | Cell editor for the grid control.
`published`
`property Align: TAlign;` |  | Specifies the placement of the control on its Parent control.
`property AlternateColor: TColor;` |  | Color used for the background in alternate rows in the grid.
`property Anchors: TAnchors;` |  | The set of anchor definitions for this control.
`property AutoAdvance: TAutoAdvance;` |  | Direction used when automatically moving the selection to the next selectable cell.
`property AutoEdit: Boolean;` |  | Indicates if edit mode is automatically entered when a cell is selected.
`property AutoFillColumns: Boolean;` |  | Indicates whether columns are automatically resized to fill the visible area in the grid.
`property BiDiMode: TBiDiMode;` |  | Indicates whether text controls use in bi-directional reading.
`property BorderSpacing: TControlBorderSpacing;` |  | Determines the inner and outer border spacing for this control.
`property BorderStyle: TBorderStyle;` |  | Indicates the border style displayed around the control.
`property CellHintPriority: TCellHintPriority;` |  | Identifies how text is combined to form the Hint property.
`property Color: TColor;` |  | The background color for the control.
`property ColCount: Integer;` |  | Number of columns in the grid.
`property ColRowDraggingCursor: TCursor;` |  | Cursor shape displayed when a column or row is dragged in the grid control.
`property ColRowDragIndicatorColor: TColor;` |  | Color used to render the drag cursor when a column or row is dragged in the grid.
`property ColSizingCursor: TCursor;` |  | Cursor shape displayed when a column is resized.
`property ColumnClickSorts: Boolean;` |  | Indicates if clicking a column header changes its sort order.
`property Columns: TGridColumns;` |  | Definitions for the columns displayed the grid.
`property Constraints: TSizeConstraints;` |  | Contains the minimum and maximum Width and Height for the control.
`property DefaultColWidth: Integer;` |  | Default width used for grid columns.
`property DefaultDrawing: Boolean;` |  | Indicates if the default drawing mechanism is used to draw the background and text for cells.
`property DefaultRowHeight: Integer;` |  | Default row height for newly created grid rows.
`property DoubleBuffered: Boolean;` |  | When enabled, it reduces flicker when the control is painted.
`property DragCursor: TCursor;` |  | The cursor shape shown during a drag operation.
`property DragKind: TDragKind;` |  | Indicates the action performed for a drag operation: drag-and-drop or drag-and-dock.
`property DragMode: TDragMode;` |  | Determines how a drag operation is started for the control.
`property Enabled: Boolean;` |  | Determines whether the control responds to mouse or keyboard input.
`property ExtendedSelect: Boolean;` |  | Controls whether extending the current cell selection(s) on the control is enabled.
`property FadeUnfocusedSelection: Boolean;` |  | Indicates if a special color is used for selected cells when the control loses focus.
`property FixedColor: TColor;` |  | The color used for the fixed cells in the grid.
`property FixedCols: Integer;` |  | The number of fixed columns in the grid.
`property FixedRows: Integer;` |  | Number of the fixed rows in the grid.
`property Flat: Boolean;` |  | Indicates if cells are displayed using a Flat appearance.
`property FocusColor: TColor;`
`property FocusRectVisible: Boolean;`
`property Font: TFont;` |  | The font to be used for text display in this control.
`property GridLineColor: TColor;` |  | Color used for the grid lines on the control.
`property GridLineStyle: TPenStyle;` |  | Style used to draw the grid lines on the control.
`property GridLineWidth: Integer;` |  | Width (thickness) for grid lines drawn on the control.
`property HeaderHotZones: TGridZoneSet;` |  | Contains the grid zones which are hot-lighted (hovered) on the control.
`property HeaderPushZones: TGridZoneSet;` |  | Contains the grid zones which are drawn in a "pushed" state on the control.
`property ImageIndexSortAsc: TImageIndex;` |  | Ordinal position for the image used when a column is sorted in ascending order.
`property ImageIndexSortDesc: TImageIndex;` |  | Ordinal position for the image used when a column is sorted in descending order.
`property MouseWheelOption: TMouseWheelOption;` |  | Sets the mouse wheel behavior for the grid control.
`property Options: TGridOptions;` |  | Contains the set of optional features and/or behaviors enabled for the grid control.
`property Options2: TGridOptions2;` |  | Contains additional options for scrolling and editor behavior enabled in the grid control.
`property ParentBiDiMode: Boolean;` |  | Indicates whether the BiDiMode settings in the Parent control are used.
`property ParentColor: Boolean;` |  | Uses the Color from the Parent control when enabled.
`property ParentDoubleBuffered: Boolean;` |  | Value for the DoubleBuffered property in a Parent control.
`property ParentFont: Boolean;` |  | Indicates if the Font from the Parent control is used in the control.
`property ParentShowHint: Boolean;` |  | If True, the value of ShowHint for the control will be the same as the one from the Parent. Default is True.
`property PopupMenu: TPopupMenu;` |  | A context-sensitive menu that pops up when the right mouse button is clicked over this control.
`property RangeSelectMode: TRangeSelectMode;` |  | Controls the range selection mode used for the grid.
`property RowCount: Integer;` |  | Number of rows in the grid.
`property RowSizingCursor: TCursor;` |  | Cursor shape displayed when the row height is resized.
`property ScrollBars: TScrollStyle;` |  | Scrollbars displayed for the grid control.
`property ShowHint: Boolean;` |  | Enables Hint display for the control.
`property TabAdvance: TAutoAdvance;` |  | Controls the behavior for Tab navigation in the grid control.
`property TabOrder: TTabOrder;` |  | Indicates the navigation order for the control when the user presses the Tab or Shift+Tab key.
`property TabStop: Boolean;` |  | Allows the user to navigate to / from the control by pressing the Tab or Shift+Tab keys.
`property TitleFont: TFont;` |  | The font used for text in a column title.
`property TitleImageList: TCustomImageList;` |  | The list with images displayed in column titles.
`property TitleStyle: TTitleStyle;` |  | The drawing style used for the fixed column titles.
`property UseXORFeatures: Boolean;` |  | When True, the dotted focus rectangle is painted using an XOR raster operation.
`property Visible: Boolean;` |  | Allows the control, and all of its children, to be displayed or hidden.
`property OnAfterSelection: TOnSelectEvent;` |  | Event handler signalled after a new Selection is made in the grid.
`property OnBeforeSelection: TOnSelectEvent;` |  | Event handler signalled before changing the Selection in the grid control.
`property OnCellProcess: TCellProcessEvent;` |  | Event handler signalled when copying or pasting content for Cells in the grid.
`property OnChangeBounds: TNotifyEvent;` |  | Event handler signalled when the Bounds for the control have been changed.
`property OnCheckboxToggled: TToggledCheckboxEvent;` |  | Event handler signalled when the value for a check box cell is toggled.
`property OnClick: TNotifyEvent;` |  | Notification handler for mouse clicks.
`property OnColRowDeleted: TGridOperationEvent;` |  | Event handler signalled when a grid column or row is deleted.
`property OnColRowExchanged: TGridOperationEvent;` |  | Event handler signalled when a column or row has been exchanged with another.
`property OnColRowInserted: TGridOperationEvent;` |  | Event handler signalled when a column or row is inserted into the grid.
`property OnColRowMoved: TGridOperationEvent;` |  | Event handler signalled when a column or row in the grid is moved.
`property OnCompareCells: TOnCompareCells;` |  | Event handler signalled to compare the content in cells
`property OnContextPopup: TContextPopupEvent;` |  | Invoked when a context-sensitive pop-up menu is requested.
`property OnDragDrop: TDragDropEvent;` |  | Event handler signalled when an object is dropped onto the control.
`property OnDragOver: TDragOverEvent;` |  | Event handler signalled when a control is dragged over the control instance.
`property OnDblClick: TNotifyEvent;` |  | Event handler signalled when a mouse double click occurs in the control.
`property OnDrawCell: TOnDrawCell;` |  | Event handler signalled to draw a cell in the grid control.
`property OnEditButtonClick: TNotifyEvent; deprecated ;` |  | Deprecated. Use OnButtonClick instead.
`property OnButtonClick: TOnSelectEvent;` |  | Event handler signalled when a button-style cell Editor control is clicked.
`property OnEditingDone: TNotifyEvent;` |  | Event handler signalled when editing is completed for the control.
`property OnEndDock: TEndDragEvent;` |  | Event handler signalled for the end of a drag-dock operation.
`property OnEndDrag: TEndDragEvent;` |  | Event handler signalled for the end of a drag-drop operation.
`property OnEnter: TNotifyEvent;` |  | Event handler signalled when the control receives focus.
`property OnExit: TNotifyEvent;` |  | Event handler signalled when the control loses focus.
`property OnGetCellHint: TGetCellHintEvent;` |  | Gets the hint text for a cell.
`property OnGetCheckboxState: TGetCheckboxStateEvent;` |  | Event handler signalled to get the state for a check box cell.
`property OnGetEditMask: TGetEditEvent;` |  | Event handler signalled to get the edit mask used for a grid cell.
`property OnGetEditText: TGetEditEvent;` |  | Event handler signalled to get the value for a cell editor in the grid.
`property OnHeaderClick: THdrEvent;` |  | Event handler signalled when the fixed header for a column or row is clicked.
`property OnHeaderSized: THdrEvent;` |  | Event handler signalled when a column or row header has been resized.
`property OnHeaderSizing: THeaderSizingEvent;` |  | Event handler signalled when a column or row header sizing action is started.
`property OnKeyDown: TKeyEvent;` |  | Event handler signalled for key down keyboard events.
`property OnKeyPress: TKeyPressEvent;` |  | Event handler signalled for character data entered by the user.
`property OnKeyUp: TKeyEvent;` |  | Event handler signalled when a key up event has occurred for the control.
`property OnMouseDown: TMouseEvent;` |  | Event handler signalled when a mouse down event is handled for the control.
`property OnMouseEnter: TNotifyEvent;` |  | Event handler signalled when the mouse pointer has entered the control.
`property OnMouseLeave: TNotifyEvent;` |  | Event handler signalled when the mouse pointer has left the control.
`property OnMouseMove: TMouseMoveEvent;` |  | Event handler signalled when the mouse pointer is moved in the control.
`property OnMouseUp: TMouseEvent;` |  | Event handler signalled when a mouse up event is handled for the control.
`property OnMouseWheel: TMouseWheelEvent;` |  | Event handler for mouse wheel turned.
`property OnMouseWheelDown: TMouseWheelUpDownEvent;` |  | Event handler signalled for a downward movement of the mouse wheel.
`property OnMouseWheelUp: TMouseWheelUpDownEvent;` |  | Event handler signalled for an upward movement of the mouse wheel.
`property OnMouseWheelHorz: TMouseWheelEvent;` |  | Event handler signalled for a horizontal movement of the mouse wheel.
`property OnMouseWheelLeft: TMouseWheelUpDownEvent;` |  | Event handler signalled for a leftward movement of the mouse wheel.
`property OnMouseWheelRight: TMouseWheelUpDownEvent;` |  | Event handler signalled for a rightward movement of the mouse wheel.
`property OnPickListSelect: TNotifyEvent;` |  | Event handler signalled when an item is selected from a pick list-style Editor control.
`property OnPrepareCanvas: TOnPrepareCanvasEvent;` |  | Event handler signalled to prepare the Canvas to draw the grid.
`property OnResize: TNotifyEvent;` |  | Notification handler for a resize of the control.
`property OnSelectEditor: TSelectEditorEvent;` |  | Event handler signalled to select an Editor control for the current grid cell.
`property OnSelection: TOnSelectEvent;` |  | Event handler signalled when an area is selected in the grid control.
`property OnSelectCell: TOnSelectCellEvent;` |  | Event handler signalled when a grid cell is selected.
`property OnSetCheckboxState: TSetCheckboxStateEvent;` |  | Event handler signalled to set the state for a check box cell.
`property OnSetEditText: TSetEditEvent;` |  | Event handler signalled when the text in the cell Editor is assigned.
`property OnShowHint: TControlShowHintEvent;` |  | Event handler signalled when a hint window is displayed for the control.
`property OnStartDock: TStartDockEvent;` |  | Event handler for the start of a docking operation.
`property OnStartDrag: TStartDragEvent;` |  | Event handler signalled for the start of a dragging operation.
`property OnTopLeftChanged: TNotifyEvent;` |  | Event handler signalled when the top left cell in the visible area of the control is changed.
`property OnUserCheckboxBitmap: TUserCheckBoxBitmapEvent;` |  | Event handler signalled to get the user-defined bitmap used for a check box cell.
`property OnUserCheckboxImage: TUserCheckBoxImageEvent;` |  | Event handler signalled to get the user-defined image used for a check box cell.
`property OnUTF8KeyPress: TUTF8KeyPressEvent;` |  | Handler for a character entered by the user.
`property OnValidateEntry: TValidateEntryEvent;` |  | Event handler signalled to perform validation for a cell value.
`end;`

## Inheritance

`TStringGrid` |  | Implements a grid specialized for textual content.
`TCustomStringGrid` |  | The base class for TStringGrid.
`TCustomDrawGrid` |  | The base class for a custom-drawn grid control.
`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`
?
`TObject`

## Description

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

## See also

TCustomStringGrid |  | The base class for TStringGrid.
HowToUseGrids |  | How to use Grids including StringGrids, DrawGrids and DbGrids.