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

type TCustomDBGrid = class(TCustomGrid)

protected

  procedure AddAutomaticColumns;

  

Automatically adds a column definition for each Field in the dataset.

  procedure AssignTo(); override;

  

Copies property values to the specified persistent object.

  procedure AutoAdjustColumn(); override;

  

Adjust properties in the specified column to display the longest value.

  procedure BeforeMoveSelection(); override;

  

Performs actions needed before the selected column in the grid is changed.

  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;

  

Makes column sizes invalid, recalculates column sizes and refreshes the control.

  procedure ColRowMoved(); override;

  

Signals event handlers when a row or a column is moved in the grid control.

  function ColumnEditorStyle();

  

ColumnEditorStyle gets the button style for the column being edited.

  function CreateColumns; override;

  

Creates the Columns collection for the grid control.

  procedure CreateWnd; override;

  

CreateWnd - creates the window adjusts its layout and adds scroll bars when needed.

  procedure DefineProperties(); override;

  

Re-implements the inherited method to prevent reading or writing unused properties.

  procedure DefaultDrawCell();

  

Default method used to drawing a cell at the specified location.

  function DefaultEditorStyle();

  

Gets the default editor style for the specified field.

  procedure DoCopyToClipboard; override;

  

Copies the field value for the current column and row to the clipboard.

  procedure DoExit; override;

  

DoExit closes the editor and the datalink for the control.

  function DoMouseWheelDown(); override;

  

Handles mouse wheel down events in the grid control.

  function DoMouseWheelUp(); override;

  

Handles a mouse wheel up event in the grid control.

  procedure DoOnChangeBounds; override;

  

Calls the inherited method and adjusts the size and layout for the control when needed.

  procedure DoPrepareCanvas(); override;

  

Prepares the canvas and signals the OnPrepareCanvas event handler.

  procedure DoLoadColumn(); override;

  

Loads a column definition from an XML configuration file.

  procedure DoSaveColumn(); override;

  

Saves the specified column definition to the specified XML configuration file.

  procedure DrawAllRows; override;

  

Draws all data rows in grid control.

  procedure DrawFocusRect(); override;

  

Draws the current selection in the grid in a focused state.

  procedure DrawRow(); override;

  

Draws the specified row in the grid control.

  procedure DrawCell(); override;

  

DrawCell renders the specified grid cell using the specified drawing state.

  procedure DrawCellBackground();

  

Draws the background for the cell at the specified coordinates.

  procedure DrawCheckboxBitmaps();

  

Draws a check box bitmap for the specified Boolean column.

  procedure DrawFixedText();

  

Draws the fixed text at the specified row and column numbers.

  procedure DrawColumnText(); override;

  

Draws the text for the cell at the specified coordinates.

  procedure DrawIndicator(); virtual;

  

Draws the row indicator for the grid control with cues for dataset and multi-selection state.

  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 determines if the editor can be enabled for the selected cell in the control.

  procedure EditorTextChanged(); override;

  

Applies a changed value from a cell Editor to the grid control.

  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;

  

Gets the position for the first column in the grid control after the optional row indicator column.

  function GetBufferCount; virtual;

  

Gets the number of rows to buffer in the grid control.

  function GetCellHintText(); override;

  

Gets the hint text for a data cell in the grid control.

  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 specified 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 specified 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 check box at the specified location.

  function GetIsCellSelected(); override;

  

Determines if the cell at the specified location is currently selected.

  function GetIsCellTitle(); override;

  

Determines whether the specified cell is a fixed title cell for the grid control.

  procedure GetSelectedState(); override;

  

Determines if a selection is available using the Focus and Options properties for the control.

  function GetSmoothScroll(); override;

  

Gets the smooth scroll setting for the horizontal scroll bar.

  function GetTruncCellHintText(); override;

  

Gets the truncated hint text for the specified cell.

  function GridCanModify;

  

Indicates if the DataLink is active and allows editing in the grid control.

  procedure GetSBVisibility(); override;

  

Determines the visibility of the horizontal and vertical scroll bars for the control.

  procedure GetSBRanges(); override;

  

Gets the range values for the scroll bars when visible.

  procedure HeaderClick(); override;

  

Performs actions needed when a column header is clicked or dragged for the grid control.

  procedure HeaderSized(); override;

  

Updates Columns in the control when a a header cell is resized.

  function IsColumnVisible();

  

Indicates if the specified column is visible using the column definition or its display width.

  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;

  

Loads values for the Options property from the specified XML configuration file.

  procedure MoveSelection; override;

  

MoveSelection changes the current selection in the control.

  function MouseButtonAllowed(); override;

  

Indicates whether the specified mouse button can be handled when mouse down messages are processed for for the grid control.

  procedure MouseDown(); override;

  

Handles mouse down messages in the control and signals the OnMouseDown event handler.

  procedure MouseMove(); override;

  

Signals the OnMouseMove event handler for the grid control.

  procedure PrepareCanvas(); override;

  

Prepares the Canvas to render the specified cell with the drawing state in aState.

  procedure PrepareCellHints(); override;

  

Sets the active record in the grid to the specified row.

  procedure RemoveAutomaticColumns;

  

Removes automatic columns added to the grid control.

  procedure SaveGridOptions(); override;

  

Saves values in the Options property to the specified XML configuration file.

  procedure SelectEditor; override;

  

Gets the editor used for the SelectedField in the control.

  procedure SetEditText(); override;

  

Sets the textual value for the editor in the specified cell.

  procedure SetFixedCols(); override;

  

Sets the value for the FixedCols property.

  procedure UnprepareCellHints; override;

  

Restores the record that was active when PrepareCellHints was called.

  procedure UpdateActive; virtual;

  

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

  procedure UpdateAutoSizeColumns;

  

Calculates the width for auto-sized columns and refreshes the grid control.

  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 for the grid control.

  procedure WMVScroll(); message;

  

Handles the LM_VScroll message for the control.

  procedure WndProc(); override;

  

Extends the message processing loop for the database grid control.

  property Columns: TDBGridColumns; [rw]

  

Columns provides access to columns defined for the database grid control.

  property FixedRowsExtra: Integer; [rw]

  

Reserves additional rows in the fixed header area for the control.

  property GridStatus: TDbGridStatus; [rw]

  

Stores status information about operations active for the grid control.

  property Datalink: TComponentDataLink; [r]

  

Datalink for the component with event handlers for the linked dataset.

  property Options: TDbGridOptions; [rw]

  

Contains the optional features or behaviors that are enabled for the grid control.

  property OptionsExtra: TDbGridExtraOptions; [rw]

  

Contains the extra options enabled for the database grid control.

  property ReadOnly: Boolean; [rw]

  

Indicates if modifications are allowed in the grid control.

  property SelectedRows: TBookmarkList; [r]

  

SelectedRows are the recorded rows in a bookmark list.

  property OnCellClick: TDBGridClickEvent; [rw]

  

Event handler signalled for a mouse click in a grid column.

  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]

  

Event handler signalled to get the hint text for a cell in the grid control.

  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 check box entry on the grid.

  property OnUserCheckboxState: TDbGridCheckboxStateEvent; [rw]

  

Event handler signalled to get a user-specified value for a check box editor on the grid control.

  property OnRowMoved: TMovedEvent; [rw]

  

Event handler signalled when a row is moved on the grid control.

public

  constructor Create(); override;

  

Constructor for the class instance.

  procedure AutoAdjustColumns; override;

  

Updates the widths for automatically-sized columns in the grid control.

  procedure InitiateAction; override;

  

Updates the ActionLink for the control and resets flag values in GridStatus.

  procedure DefaultDrawColumnCell();

  

Default method used to draw cells in a specified column for the grid control.

  function EditorByStyle(); override;

  

Gets an editor control which uses the specified button style.

  procedure ResetColWidths;

  

Restores column widths to their default values.

  destructor Destroy; override;

  

Destroy is the destructor for TCustomDbGrid

  function MouseToRecordOffset();

  

Gets the grid zone and record offset for the cell at the specified mouse coordinates.

  function ExecuteAction(); override;

  

Executes the specified action in the DataLink for the grid control.

  function UpdateAction(); override;

  

Updates the specified action using the DataLink for the grid control.

  procedure SaveToFile(); override;

  

Sets SaveOptions to write design-time settings for the grid, and stores the values to the specified file name.

  procedure SaveToStream(); override;

  

Sets SaveOptions to write design-time settings for the grid, and stores the values to the specified stream.

  procedure LoadFromFile(); override;

  

Loads design-time settings for the grid control from the specified file name.

  procedure LoadFromStream(); override;

  

Loads design-time setting for the grid control from the specified stream.

  property AllowOutboundEvents: Boolean;

  

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

  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]

  

Display rectangle for the selected cell in the grid control.

  property LastColumn: TColumn; [r]

  

Contains the last visible column in the grid control.

  property FirstColumn: TColumn; [r]

  

Contains the first visible column for the grid control.

  property DataSource: TDataSource; [rw]

  

Provides access to the dataset displayed in the grid.

end;

Inheritance

TCustomDBGrid

  

TCustomDBGrid is the base class for TDBGrid.

|

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

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

How To Use Grids

  

How to use Grids including StringGrids, DrawGrids and DbGrids.

How To Use Data-Aware Controls

  

HowToUseDataAwareControls - Hints for accessing databases.


Version 3.2 Generated 2024-02-25 Home