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

TCustomDBGrid

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

TCustomDBGrid - the base class for TDBGrid , for displaying database information in the manner of a StringGrid

Declaration

Source position: dbgrids.pas line 275

type TCustomDBGrid = class(TCustomGrid)

protected

  procedure AddAutomaticColumns;

  

AddAutomaticColumns add as many columns as there are fields in the dataset; do this only at runtime.

  procedure AssignTo(); override;

  procedure BeforeMoveSelection(); override;

  

BeforeMoveSelection - method to use before a selection is moved

  procedure BeginLayout;

  

BeginLayout starts producing the layout for the grid

  procedure CellClick(); override;

  

CellClick - calls the OnCellClickevent handler if it is assigned for this particular cell

  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 - returns a button style appropriate to the kind of column being edited

  function CreateColumns; override;

  

CreateColumns - returns the identity of the created columns

  procedure CreateWnd; override;

  

CreateWnd - creates the window: calls inherited CreateWnd and adjusts layout if needed, in particular putting in scrollbars

  procedure DefineProperties(); override;

  procedure DefaultDrawCell();

  

DefaultDrawCell - the default method for drawing a cell at the specified location, depending on the type of cell

  function DefaultEditorStyle();

  procedure DoExit; override;

  

DoExit - closes down data links and calls inherited DoExit

  function DoMouseWheelDown(); override;

  

DoMouseWheelDown - calls the OnMouseWheelDown event handler if assigned, and adjusts position of pointer over the link

  function DoMouseWheelUp(); override;

  

DoMouseWheelUp - calls the OnMouseWheelUp event handler if assigned, and adjusts position of pointer over the link

  procedure DoOnChangeBounds; override;

  

DoOnChangeBounds - calls inherited DoOnChangeBounds, adjusts layout if required

  procedure DoPrepareCanvas(); override;

  

DoPrepareCanvas - calls the OnPrepareCanvas event handler if assigned

  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 - draws a cell at the given grid location (Col, Row) or in the specified Rectangle

  procedure DrawCheckboxBitmaps();

  

DrawCheckboxBitmaps calls DrawGridCheckboxBitmaps after checking that datatype of relevant cell is boolean

  procedure DrawFixedText();

  

DrawFixedText draws the text in a fixed row

  procedure DrawColumnText(); override;

  procedure DrawIndicator(); virtual;

  procedure EditingColumn();

  

EditingColumn - the Ok status is true if the data are being modified over the link

  procedure EditorCancelEditing;

  

EditorCancelEditing - cancels changes and disables editing processes

  procedure EditorDoGetValue; override;

  

EditorDoGetValue - calls inherited EditorDoGetValue and performs UpdateData

  function EditorCanAcceptKey(); override;

  

EditorCanAcceptKey checks the integrity of the datalink and that the key and field are valid character entities

  function EditorIsReadOnly; override;

  

EditorIsReadOnly - returns True if the Editor has Read Only status

  procedure EditorTextChanged(); override;

  procedure EndLayout;

  

EndLayout - finishes modifying layout

  function FieldIndexFromGridColumn();

  

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

  function FirstGridColumn; override;

  function GetBufferCount;

  

GetBufferCount - returns the size of the buffer

  function GetDefaultColumnAlignment(); override;

  

GetDefaultColumnAlignment - gets a default alignment from the stated column if it has one, otherwise supplies a default LeftJustify alignment

  function GetDefaultColumnWidth(); override;

  

GetDefaultColumnWidth - calls DefaultFieldColWidth (private function)

  function GetDefaultColumnReadOnly(); override;

  

GetDefaultColumnReadOnly - finds default ReadOnly status for column from data link

  function GetDefaultColumnTitle(); override;

  

GetDefaultColumnTitle - returns the display name from the nominated grid column

  function GetDefaultRowHeight; override;

  

GetDefaultRowHeight calls inherited GetDefaultRowHeight and makes it a little smaller

  function GetDsFieldFromGridColumn();

  

GetDsFieldFromGridColumn - returns the identity of the DataSet field corresponding to the nominated grid column

  function GetEditMask(); override;

  

GetEditMask - checks datalink, finds field value and calls OnFieldEditMask if it is assigned

  function GetEditText(); override;

  

GetEditText - checks the datalink, finds field and loads its text

  function GetFieldFromGridColumn();

  

GetFieldFromGridColumn obtain the field either from a Db column or directly from dataset fields

  function GetGridColumnFromField();

  

GetGridColumnFromField - obtain the corresponding grid column for the given field

  function GetImageForCheckBox(); override;

  

  function GetIsCellSelected(); override;

  

GetIsCellSelected - returns True if the given cell is selected

  function GetIsCellTitle(); override;

  procedure GetSelectedState(); override;

  function GridCanModify;

  

GridCanModify returns True if datalink is active and allows editing, and readonly is not set

  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 IsValidChar();

  

IsValidChar - returns True if the supplied field contains a valid ASCII or UTF8 character

  procedure KeyDown(); override;

  

KeyDown - checks key for a number of special cases, and calls the OnKeyDown event handler if assigned, otherwise calls inherited KeyDown

  procedure LinkActive(); virtual;

  

LinkActive - if False, calls RemoveAutomaticColumns and LayoutChanged

  procedure LayoutChanged; virtual;

  

LayoutChanged - links columns to fields, inserts any required automatic columns

  procedure Loaded; override;

  

  procedure MoveSelection; override;

  

MoveSelection - calls inherited MoveSelection and updates the Active state

  procedure MouseDown(); override;

  

MouseDown - checks for a number of special cases and calls the OnMouseDown event handler, or calls inherited MouseDown

  procedure MouseMove(); override;

  

MouseMove - a procedure that allows the programmer to simulate a mouse being moved over the control, and initiates the same Action as that associated with the OnMouseMove event

  procedure PrepareCanvas(); override;

  

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

  procedure RemoveAutomaticColumns;

  

RemoveAutomaticColumns - strips out any automatic columns from the grid

  procedure ResetSizes; 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;

  

  procedure UpdateActive; virtual;

  

UpdateActive - updates the Active status for the field and record

  procedure UpdateAutoSizeColumns;

  procedure UpdateData; virtual;

  

UpdateData - implements any pending changes in the data: uses a method appropriate to the data type of the field

  function UpdateGridCounts;

  

UpdateGridCounts - modifies the total sizes allowing for any pending changes

  procedure WMVScroll(); message;

  

WMVScroll - system message for vertical scrolling

  procedure WndProc(); override;

  

WndProc - message handler for the procedure of this window

  property Columns: TDBGridColumns; [rw]

  

  property GridStatus: TDbGridStatus; [rw]

  

GridStatus - the status of the grid (whether updating, removing auto columns etc)

  property DataSource: TDataSource; [rw]

  

The DataSource from which this grid displays - usually the result of a database Query

  property Options: TDbGridOptions; [rw]

  

The options available for use in this grid

  property OptionsExtra: TDbGridExtraOptions; [rw]

  

OptionsExtra - the extra options for this grid

  property ReadOnly: Boolean; [rw]

  

Set True to prevent writing to grid; set False to allow modification

  property SelectedRows: TBookmarkList; [r]

  

SelectedRows - recorded as a bookmark list

  property OnCellClick: TDBGridClickEvent; [rw]

  

Event handler for mouse click in a cell of the grid

  property OnColEnter: TNotifyEvent; [rw]

  

Event handler if mouse enters column or it gains focus

  property OnColExit: TNotifyEvent; [rw]

  

Event handler if mouse leaves column or it loses focus

  property OnColumnMoved: TMovedEvent; [rw]

  

OnColumnMoved - event handler for moving a column

  property OnColumnSized: TNotifyEvent; [rw]

  

OnColumnSized - event handler for re-sizing a column

  property OnDrawColumnCell: TDrawColumnCellEvent; [rw]

  

Event handler if the cell in this column requires to be drawn

  property OnFieldEditMask: TGetDbEditMaskEvent; [rw]

  

Event handler if field is associated with an edit mask

  property OnPrepareCanvas: TPrepareDbGridCanvasEvent; [rw]

  

OnPrepareCanvas - event handler for preparing canvas

  property OnSelectEditor: TDbGridSelEditorEvent; [rw]

  

OnSelectEditor - event handler for selecting editor

  property OnTitleClick: TDBGridClickEvent; [rw]

  

Event handler for mouse click on Title

  property OnUserCheckboxBitmap: TDbGridCheckBoxBitmapEvent; [rw]

  

OnUserCheckboxBitmap - event handler: user-defined bitmap for checkboxes

public

  constructor Create(); override;

  

Create - constructor for TCustomDBGrid: calls inherited Create then sets up datalink events, options and defaults

  procedure AutoSizeColumns;

  procedure InitiateAction; override;

  

Initiate the action associated with this control

  procedure DefaultDrawColumnCell();

  

DefaultDrawColumnCell - the default method for drawing cells in this column

  function EditorByStyle(); override;

  

Select a cell editor control with the specified style

  procedure ResetColWidths;

  

ResetColWidths - restore the column widths to their default values

  destructor Destroy; override;

  

Destroy - destructor for TCustomDbGrid: frees rows, frees the datalink, calls inherited Destroy

  property SelectedField: TField; [rw]

  

The selected field, for editing, data input or simply viewing

  property SelectedIndex: Integer; [rw]

  

Selected index - number of the row selected for viewing or editing

  property SelectedColumn: TColumn; [r]

  

The selected column for viewing or editing

  property SelectedFieldRect: TRect; [r]

  property ThumbTracking: Boolean; [rw]

  

ThumbTracking - returns True if thumb tracking is used

end;

Inheritance

TCustomDBGrid

  

TCustomDBGrid - the base class for TDBGrid , for displaying database information in the manner of a StringGrid

|

TCustomGrid

  

TCustomGrid - the base class for all grid controls

|

TCustomControl

  

TCustomControl - a base class for many window controls

|

TWinControl

|

TControl

|

TLCLComponent

  

TLCLComponent - base class for LCL components

|

TComponent,IUnknown,IInterfaceComponentReference

|

TPersistent

|

TObject

See also

HowToUseDataAwareControls

  

HowToUseDataAwareControls - Hints for accessing databases

HowToUseGrids

  

How to use Grids including StringGrids, DrawGrids and DbGrids

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