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

TCustomDBGrid

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

TCustomDBGrid is the base class for TDBGrid

Declaration

Source position: dbgrids.pas line 322

type TCustomDBGrid = class(TCustomGrid)

protected

  procedure AddAutomaticColumns;

  

Adds a column for each Field in the dataset

  procedure AssignTo(); override;

  procedure AutoAdjustColumn(); override;

  procedure BeforeMoveSelection(); override;

  

BeforeMoveSelection - method to use before a selection is moved

  procedure BeginLayout;

  

BeginLayout starts producing layout changes for the grid control

  procedure CellClick(); override;

  

CellClick calls the OnCellClick event handler if it is assigned for this particular cell

  function CheckDisplayMemo();

  

Indicates if the field is a Memo that needs to be displayed in the grid

  procedure InvalidateSizes;

  

InvalidateSizes renders the Sizes non-valid

  procedure ColRowMoved(); override;

  

ColRowMoved - the column or row (determined by IsColumn) is moved from one index to another

  function ColumnEditorStyle();

  

ColumnEditorStyle gets the button style for the column being edited

  function CreateColumns; override;

  

CreateColumns - returns the identity of the created columns

  procedure CreateWnd; override;

  

CreateWnd - creates the window adjusts its layout and adds scrollbars when needed

  procedure DefineProperties(); override;

  procedure DefaultDrawCell();

  

Default method used to drawing a cell at the specified location

  function DefaultEditorStyle();

  procedure DoCopyToClipboard; override;

  procedure DoExit; override;

  

DoExit closes the editor and the datalink for the control

  function DoMouseWheelDown(); override;

  

Handle mouse wheel down events in the grid control

  function DoMouseWheelUp(); override;

  

Handle mouse wheelup events in the grid control

  procedure DoOnChangeBounds; override;

  

DoOnChangeBounds - calls inherited DoOnChangeBounds adjusts layout if required

  procedure DoPrepareCanvas(); override;

  

Prepares the canvas and signals OnPrepareCanvas

  procedure DoLoadColumn(); override;

  procedure DoSaveColumn(); override;

  procedure DrawAllRows; override;

  

DrawAllRows - draws all the rows

  procedure DrawFocusRect(); override;

  

DrawFocusRect - draw a rectangle with focus in the nominated cell

  procedure DrawRow(); override;

  

DrawRow - draws the specified row

  procedure DrawCell(); override;

  

DrawCell renders the specified grid cell in the supplied drawing state

  procedure DrawCellBackground();

  procedure DrawCheckboxBitmaps();

  

Draws a Checkbox bitmap for the specified Boolean column

  procedure DrawFixedText();

  

Draws the fixed text at the specified row and column numbers

  procedure DrawColumnText(); override;

  procedure DrawIndicator(); virtual;

  procedure EditingColumn();

  

EditingColumn sets or resets the column being edited in the control

  procedure EditorCancelEditing;

  

EditorCancelEditing cancels pending changes and disables the editor

  procedure EditorDoGetValue; override;

  

EditorDoGetValue gets the value used in the editor for the control

  function EditorCanAcceptKey(); override;

  

EditorCanAcceptKey determines if the specified character can be applied to the Field for the editor

  function EditorIsReadOnly; override;

  

EditorIsReadOnly - returns True if the Editor has Read Only status

  procedure EditorTextChanged(); override;

  procedure EndLayout;

  

EndLayout finishes layout changes for the control

  function FieldIndexFromGridColumn();

  

FieldIndexFromGridColumn returns the index for the database Field corresponding to the stated grid column

  function FirstGridColumn; override;

  function GetBufferCount; virtual;

  

Gets the number of rows to buffer in the grid control

  function GetCellHintText(); override;

  function GetDefaultColumnAlignment(); override;

  

Gets the default alignment for the column

  function GetDefaultColumnWidth(); override;

  

Gets the default width for the specified column

  function GetDefaultColumnReadOnly(); override;

  

Gets the default ReadOnlyvalue for the specifed column

  function GetDefaultColumnTitle(); override;

  

Gets the default title displayed for the specified column

  function GetDefaultRowHeight; override;

  

Get the default row height for records displayed in the grid

  function GetDsFieldFromGridColumn();

  

GetDsFieldFromGridColumn returns the identity of the dataset Field corresponding to the nominated grid column

  function GetEditMask(); override;

  

GetEditMask gets the EditMask for the Field at the specied Row and Column

  function GetEditText(); override;

  

GetEditText gets the Text value for the specified Field

  function GetFieldFromGridColumn();

  

GetFieldFromGridColumn obtain the Field either from a Db column or directly from dataset Fields

  function GetGridColumnFromField();

  

GetGridColumnFromField - gets the corresponding grid column for the given Field

  procedure GetImageForCheckBox(); override;

  

Gets the bitmap displayed for a Checkbox at the specified location

  function GetIsCellSelected(); override;

  

GetIsCellSelected - returns True if the given cell is selected

  function GetIsCellTitle(); override;

  procedure GetSelectedState(); override;

  function GetSmoothScroll(); override;

  function GetTruncCellHintText(); override;

  function GridCanModify;

  

GridCanModify indicates if the DataLink is active and allows editing

  procedure GetSBVisibility(); override;

  

GetSBVisibility - finds the values of the visibility flags for the scrollbars

  procedure GetSBRanges(); override;

  

GetSBRanges - finds the ranges of values for the scrollbars, if they are visible

  procedure HeaderClick(); override;

  

HeaderClick - calls OnHeaderClick if assigned

  procedure HeaderSized(); override;

  

HeaderSized - method to deal with re-sizing of a column (IsColumn True) or row header

  function IsColumnVisible();

  function IsValidChar();

  

IsValidChar indicates if the specified Field contains the specified UTF-8 character

  procedure KeyDown(); override;

  

KeyDown handles special keys and signals the OnKeyDown event handler

  procedure LinkActive(); virtual;

  

LinkActive updates the control after a change to the state of its DataLink

  procedure LayoutChanged; virtual;

  

LayoutChanged links columns to Fields and inserts any required automatic columns

  procedure Loaded; override;

  

Performs layout operations after the control is loaded at run-time

  procedure LoadGridOptions(); override;

  procedure MoveSelection; override;

  

MoveSelection changes the current selection in the control

  function MouseButtonAllowed(); override;

  procedure MouseDown(); override;

  

MouseDown handles mouse down messages in the control and signals the OnMouseDown event handler

  procedure MouseMove(); override;

  

Handler for MouseMove events.

  procedure PrepareCanvas(); override;

  

PrepareCanvas - method to get the canvas ready for drawing at the specified location

  procedure PrepareCellHints(); override;

  procedure RemoveAutomaticColumns;

  

Removes automatic columns added to the grid control

  procedure ResetSizes; override;

  procedure SaveGridOptions(); override;

  procedure SelectEditor; override;

  

SelectEditor - chooses the editor for current use

  procedure SetEditText(); override;

  

SetEditText - specifies the text-string to be placed in the Editor for processing

  procedure SetFixedCols(); override;

  function SelectCell(); override;

  

Indicates if the cell at the specified coordinates can be selected in the control

  procedure UnprepareCellHints; override;

  procedure UpdateActive; virtual;

  

UpdateActive redraws the control when the active row in the dataset is changed

  procedure UpdateAutoSizeColumns;

  procedure UpdateData; virtual;

  

UpdateData is used to perform pending updates for the selected cell.

  function UpdateGridCounts;

  

Gets the total number of visible columns (or fields) in the grid

  procedure WMVScroll(); message;

  

WMVScroll - system message for vertical scrolling

  procedure WndProc(); override;

  

The general message handler for this control.

  property Columns: TDBGridColumns; [rw]

  

Columns provides access to columns defined for the database grid control

  property GridStatus: TDbGridStatus; [rw]

  

Stores status information about operations active for the grid control

  property Datalink: TComponentDataLink; [r]

  property Options: TDbGridOptions; [rw]

  

Stores values from the TDbGridOption enumeration

  property OptionsExtra: TDbGridExtraOptions; [rw]

  

Contains the extra options enabled for the grid control

  property ReadOnly: Boolean; [rw]

  

Indicates if modifications are allowed in the grid control

  property SelectedRows: TBookmarkList; [r]

  

SelectedRows - recorded as a bookmark list

  property OnCellClick: TDBGridClickEvent; [rw]

  

Event handler for mouse click in a column for the grid

  property OnColEnter: TNotifyEvent; [rw]

  

Event handler signalled when the mouse enters a column

  property OnColExit: TNotifyEvent; [rw]

  

Event handler signalled when the mouse exits a column

  property OnColumnMoved: TMovedEvent; [rw]

  

Event handler signalled when the order of a column is changed

  property OnColumnSized: TNotifyEvent; [rw]

  

Event handler signalled when a grid column has been resized

  property OnDrawColumnCell: TDrawColumnCellEvent; [rw]

  

Event handler signalled when a cell needs to be drawn

  property OnDrawColumnTitle: TDrawColumnCellEvent; [rw]

  

Event handler signalled when a cell title needs to be drawn

  property OnFieldEditMask: TGetDbEditMaskEvent; [rw]

  

Event handler signalled to get the edit mask for a Field

  property OnGetCellHint: TDbGridCellHintEvent; [rw]

  property OnPrepareCanvas: TPrepareDbGridCanvasEvent; [rw]

  

Event handler signalled to prepare the grid canvas for drawing a cell

  property OnSelectEditor: TDbGridSelEditorEvent; [rw]

  

Event handler signalled when the editor is selected for a Field in the grid

  property OnTitleClick: TDBGridClickEvent; [rw]

  

Event handler for mouse clicks on a Title cell

  property OnUserCheckboxBitmap: TDbGridCheckBoxBitmapEvent; [rw]

  

Event handler signalled to get the image used for a checkbox entry on the grid

  property OnUserCheckboxState: TDbGridCheckboxStateEvent; [rw]

  property OnRowMoved: TMovedEvent; [rw]

public

  constructor Create(); override;

  

  procedure AutoAdjustColumns; override;

  procedure InitiateAction; override;

  

Initiates the action associated with the grid control

  procedure DefaultDrawColumnCell();

  

Default method used for drawing cells in a column

  function EditorByStyle(); override;

  

Select a cell editor control with the specified style

  procedure ResetColWidths;

  

Restores column widths to their default values

  destructor Destroy; override;

  

Destroy is the destructor for TCustomDbGrid

  function MouseToRecordOffset();

  function ExecuteAction(); override;

  function UpdateAction(); override;

  procedure SaveToFile(); override;

  procedure SaveToStream(); override;

  procedure LoadFromFile(); override;

  procedure LoadFromStream(); override;

  property AllowOutboundEvents: Boolean;

  property SelectedField: TField; [rw]

  

Field that reads and writes data for the currently selected column

  property SelectedIndex: Integer; [rw]

  

Ordinal position of the selected column in the grid control

  property SelectedColumn: TColumn; [r]

  

Represents the currently selected column in the grid control

  property SelectedFieldRect: TRect; [r]

  property LastColumn: TColumn; [r]

  property FirstColumn: TColumn; [r]

  property DataSource: TDataSource; [rw]

  

Provides access to the dataset displayed in the grid

end;

Inheritance

TCustomDBGrid

  

TCustomDBGrid is the base class for TDBGrid

|

TCustomGrid

  

TCustomGrid - the base class for all grid controls

|

TCustomControl

  

The base class for windowed controls which paint themselves.

|

TWinControl

  

The base class for controls which can contain other (child) controls.

|

TControl

  

The base class for visible controls.

|

TLCLComponent

  

The base class for LCL components associated with widgets.

|

TComponent

?

TObject

Description

TCustomDBGrid is a TCustomGrid descendant and the base class for TDBGrid. TCustomDBGrid adds capabilities needed to implement a database-aware grid control. One key feature is the TComponentDataLink used to coordinate access and event handlers between the grid control and its linked dataset. Another key feature is the use of the Options and OptionsExtra properties to enable/disable features or behaviors in the grid control.

TCustomDBGrid overrides certain features from the ancestor class to provide consistent use with Fields, Field kinds, and values in TDataset.

Applications should use the TDBGrid descendant which sets the scope of properties, methods, and event handlers to public or published.

See also

HowToUseGrids

  

How to use Grids including StringGrids, DrawGrids and DbGrids

HowToUseDataAwareControls

  

HowToUseDataAwareControls - Hints for accessing databases

The latest version of this document can be found at lazarus-ccr.sourceforge.net.