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

TCustomDrawGrid

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

The base class for a custom-drawn grid control.

Declaration

Source position: grids.pas line 1396

type TCustomDrawGrid = class(TCustomGrid)

protected

  FGrid: TVirtualGrid;

  

Contains the virtual grid for the control.

  procedure CellClick(); override;

  

Performs actions to handle a mouse click in the specified cell.

  procedure ColRowDeleted(); override;

  

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

  procedure ColRowExchanged(); override;

  

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

  procedure ColRowInserted(); override;

  

Performs actions needed when a column or row is inserted at the specified position in the grid control.

  procedure ColRowMoved(); override;

  

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

  function CreateVirtualGrid; virtual;

  

Creates and returns the internal virtual grid instance for the control.

  procedure DrawCell(); override;

  

Draws the the content for the cell specified in the ACol and ARow arguments.

  procedure DrawCellAutonumbering(); virtual;

  

Draws a cell with auto-numbering.

  procedure DrawFocusRect(); override;

  

Draws the focus rectangle for the control.

  function GetCells(); override;

  

Gets the value for the specified cell.

  procedure GetCheckBoxState(); virtual;

  

Gets the check box state for the cell at the specified coordinates.

  function GetEditMask(); override;

  

Gets the edit mask for the specified cell.

  function GetEditText(); override;

  

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

  procedure GridMouseWheel(); override;

  

Performs actions when the mouse wheel is scrolled in the grid control.

  procedure HeaderClick(); override;

  

Performs actions when a mouse click occurs in a header for a grid column.

  procedure HeaderSized(); override;

  

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

  procedure HeaderSizing(); override;

  

Performs actions when resizing a column or row to the specified size.

  procedure KeyDown(); override;

  

Handles key down events for the grid control.

  procedure NotifyColRowChange();

  

Performs a notification when a column or row has been changed.

  function SelectCell(); override;

  

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

  procedure SetColor(); override;

  

Sets the value for the Color property.

  procedure SetCheckboxState(); virtual;

  

Sets the value for a check box in the specified cell to a given state.

  procedure SetEditText(); override;

  

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

  procedure SizeChanged(); override;

  

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

  procedure ToggleCheckbox; virtual;

  

Toggles the state for a check box cell between the checked and unchecked values.

  property OnGetCheckboxState: TGetCheckboxStateEvent; [rw]

  

Event handler signalled to get the state for a check box cell.

  property OnSetCheckboxState: TSetCheckboxStateEvent; [rw]

  

Event handler signalled to set the state for a check box cell.

public

  constructor Create(); override;

  

Constructor for the class instance.

  destructor Destroy; override;

  

Destructor for the class instance.

  procedure DeleteColRow();

  

Deletes a column or a row at the specified position.

  procedure DeleteCol(); virtual;

  

Deletes the column at the specified position on the grid control.

  procedure DeleteRow(); virtual;

  

Deletes the row at the specified position on the grid control.

  procedure ExchangeColRow(); virtual;

  

Exchanges column or row values at the specified positions.

  procedure InsertColRow();

  

Inserts a column or a row at the specified position.

  procedure MoveColRow();

  

Moves a column or a row from a specified position to a new position in the grid.

  procedure SortColRow();

  

Sorts the data in a column or row using the specified positions.

  procedure DefaultDrawCell(); virtual;

  

The default method used to draw the cell at the given position using a specific state.

  property AllowOutboundEvents: Boolean;

  

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

  property BorderColor: TColor;

  

The color used for the border on the control.

  property Canvas: TCanvas;

  

The drawing surface for the control.

  property Col: Integer;

  

Column index for the selected grid cell.

  property ColWidths: Integer;

  

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

  property ColRow: TPoint;

  

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

  property DisabledFontColor: TColor;

  

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

  property Editor: TWinControl;

  

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

  property EditorBorderStyle: TBorderStyle;

  

The border style for the Editor control.

  property EditorMode: Boolean;

  

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

  property ExtendedColSizing: Boolean;

  

Indicates if extended column sizing is enabled in the grid.

  property AltColorStartNormal: Boolean;

  

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

  property FastEditing: Boolean;

  

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

  property FixedGridLineColor: TColor;

  

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

  property FocusColor: TColor;

  

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

  property FocusRectVisible: Boolean;

  

Indicates if the focus rectangle is displayed for the control.

  property GridHeight: Integer;

  

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

  property GridWidth: Integer;

  

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

  property IsCellSelected: Boolean;

  

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

  property LeftCol: Integer;

  

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

  property Row: Integer;

  

Row number for the selected grid cell.

  property RowHeights: Integer;

  

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

  property SaveOptions: TSaveOptions;

  

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

  property SelectedColor: TColor;

  

Color used for selected cells in the grid.

  property SelectedColumn: TGridColumn;

  

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

  property Selection: TGridRect;

  

Rectangle with the current cell selections in the grid control.

  property StrictSort: Boolean;

  

Indicates if strict sorting is used.

  property TopRow: Integer;

  

The first visible row in the grid.

  property UseXORFeatures: Boolean;

  

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

  property Align: TAlign;

  

Specifies the placement of the control on its Parent control.

  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 AutoFillColumns: Boolean;

  

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

  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 Color: TColor;

  

The background color for the control.

  property ColCount: Integer;

  

Number of columns in the grid.

  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 Enabled: Boolean;

  

Determines whether the control responds to mouse or keyboard input.

  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 FixedHotColor: TColor;

  

The color used for hot-lighted fixed cells 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 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 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 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 RowCount: Integer;

  

Number of rows in the grid.

  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 Visible: Boolean;

  

Allows the control, and all of its children, to be displayed or hidden.

  property VisibleColCount: Integer;

  

The number of visible columns in the grid control.

  property VisibleRowCount: Integer;

  

The number of visible rows in the grid control.

  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 OnClick: TNotifyEvent;

  

Notification handler for mouse clicks.

  property OnColRowDeleted: TGridOperationEvent; [rw]

  

Event handler signalled when a grid column or row is deleted.

  property OnColRowExchanged: TGridOperationEvent; [rw]

  

Event handler signalled when a column or row has been exchanged with another.

  property OnColRowInserted: TGridOperationEvent; [rw]

  

Event handler signalled when a column or row is inserted into the grid.

  property OnColRowMoved: TGridOperationEvent; [rw]

  

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 OnDblClick: TNotifyEvent;

  

Event handler signalled when a mouse double click occurs in the control.

  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 OnDrawCell: TOnDrawCell;

  

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

  property OnEditButtonClick: TNotifyEvent; deprecated ;

  

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

  property OnButtonClick: TOnSelectEvent;

  

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

  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 OnGetEditMask: TGetEditEvent; [rw]

  

Event handler signalled to get the edit mask used for a grid cell.

  property OnGetEditText: TGetEditEvent; [rw]

  

Event handler signalled to get the value for a cell editor in the grid.

  property OnHeaderClick: THdrEvent; [rw]

  

Event handler signalled when the fixed header for a column or row is clicked.

  property OnHeaderSized: THdrEvent; [rw]

  

Event handler signalled when a column or row header has been resized.

  property OnHeaderSizing: THeaderSizingEvent; [rw]

  

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 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 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; [rw]

  

Event handler signalled when a grid cell is selected.

  property OnSetEditText: TSetEditEvent; [rw]

  

Event handler signalled when the text in the cell Editor is assigned.

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

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,IUnknown,IInterfaceComponentReference

|

TPersistent,IFPObserved

|

TObject

Description

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:

See also

TCustomGrid

  

Implements the base class for grid controls.

TDrawGrid

  

Implements a custom-drawn grid control.

TStringGrid

  

Implements a grid specialized for textual content.

TOnDrawCell

  

Defines the event handler signalled to draw a cell on a grid control.

HowToUseGrids

  

How to use Grids including StringGrids, DrawGrids and DbGrids.


Version 3.2 Generated 2024-02-25 Home